View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Ben McClave Ben McClave is offline
external usenet poster
 
Posts: 173
Default Macro to choose data and export in another workbook

Hi Jerry,

Unless I set up my test workbook differently than yours, the code seems to work fine. I think that the problem probably lies in the variables. There are only three variables to feed the code. They are found near the top:

'Assign variables
Set ws = ThisWorkbook.Sheets("ICD")
Set rFind = ws.Range("A1:A100")
sFind = ThisWorkbook.Sheets("HOME").Range("A1").Value

When the code runs, it will search:

(1) Within the "ws" sheet
(2) In the "rFind" range
(3) for the text value assigned to "sFind"

I assumed that the worksheet containing data to copy ("ws") is the sheet called "ICD", and that the range of values to search ("rFind") is in the range A1:A100 of the "ICD" sheet. I further assumed that the text we're searching for ("sFind") can be found in cell A1 of the "HOME" tab. If one of these variables is off, the code may not react as expected.

If the variables have been set correctly, please consider posting a sample version of your workbook so that I can take a look at how the code interacts with your data set.

Ben