Results 1 to 3 of 3

Thread: Excel Project Help Column search within a Column search

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2018
    Posts
    1

    Excel Project Help Column search within a Column search

    Sorry if this is the wrong location but I am struggling to complete a project at work. I need to have a macro that can look through a column to find a certain tool name and then be able to shift over to the second column and find a certain process name. This is meant to be used to copy data from one document, find the location in this document and then paste it in the correct location and repeat until the document is populated. If the process that I am suggesting is not the most optimal I am open to suggestion. Thank you for the help.

    Doc1.pdf

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,398

    Re: Excel Project Help Column search within a Column search

    This sounds like it should really be in the Office Development forum, since it looks like you want to use VBA.

    Also, I think we need some more details on exactly what you are wanting to do. Are you copying the Excel data from one spreadsheet to another, or to a Word document? Are both sheets part of the same workbook? Will the data you are searching for be on different rows for each column?

    Maybe you could post a screen capture or two. I cannot download and view the attached .pdf at my current location.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel Project Help Column search within a Column search

    you could use a SQL query to return all rows that match the tool and process, something like
    Code:
    sql = "select * from [woksheetname$] where somecolumn = 'mytool' and nextxcolumn = 'myprocess'"
    to do like this you would need to make an ADO connection to the workbook, then open a recordset using the sql criteria
    replace the worksheet and column names as appropriate, the column names will depend if your columns have headers or not
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width