Hello,
I have a macro that I need to rewrite because the data file changes. The new macro needs to be based on other cues (unlike before is was spacing and offsetting -->Im a rookie).
I need to search for three things, then return a value from a different column. Where I am running into trouble automating it, is when I try to make it work with a list. The 1st and 3rd part of the search are consistent, but not unique. The 2nd is unique. All three are in the same column. I tried a For Each rCell type thing, but it just skipped that part...Im a little lost how to cycle. Thanks in advance.
Also, while your looking, if you know of a way to consolidate the 3 searches that would be great. Like a Search for A, then search for B after A, then search for C after B.
Sub Search()
Dim rFoundCell As Range
Dim rCell As Range
Windows("FY12-Q3 Value Tracker Key Measure Summary Tables FINAL.xlsm").Activate
Sheets("Store Level Value").Activate
For Each rCell In Range("B4:B10")
Windows("FY12-Q3 Data Tables.xlsx").Activate
Sheets("Total").Select
With Columns(1)
Set c = .Find("[Q6]", LookIn:=xlValues)
c.Select
Set rFoundCell = ActiveCell
'here is my problem
Set c = .Find(rCell, After:=rFoundCell, LookIn:=xlValues)
c.Select
Set rFoundCell = ActiveCell
Set c = .Find("Bottom 2 (NET)", After:=rFoundCell, LookIn:=xlValues)
c.Select
End With
Selection.Offset(0, 14).Copy
Windows("FY12-Q3 Value Tracker Key Measure Summary Tables FINAL.xlsm").Activate
Sheets("Store Level Value").Activate
rCell.Select
Selection.Offset(0, 11).Select
Selection.PasteSpecial Paste:=xlPasteValues
Next rCell
End Sub
I have a macro that I need to rewrite because the data file changes. The new macro needs to be based on other cues (unlike before is was spacing and offsetting -->Im a rookie).
I need to search for three things, then return a value from a different column. Where I am running into trouble automating it, is when I try to make it work with a list. The 1st and 3rd part of the search are consistent, but not unique. The 2nd is unique. All three are in the same column. I tried a For Each rCell type thing, but it just skipped that part...Im a little lost how to cycle. Thanks in advance.
Also, while your looking, if you know of a way to consolidate the 3 searches that would be great. Like a Search for A, then search for B after A, then search for C after B.
Sub Search()
Dim rFoundCell As Range
Dim rCell As Range
Windows("FY12-Q3 Value Tracker Key Measure Summary Tables FINAL.xlsm").Activate
Sheets("Store Level Value").Activate
For Each rCell In Range("B4:B10")
Windows("FY12-Q3 Data Tables.xlsx").Activate
Sheets("Total").Select
With Columns(1)
Set c = .Find("[Q6]", LookIn:=xlValues)
c.Select
Set rFoundCell = ActiveCell
'here is my problem
Set c = .Find(rCell, After:=rFoundCell, LookIn:=xlValues)
c.Select
Set rFoundCell = ActiveCell
Set c = .Find("Bottom 2 (NET)", After:=rFoundCell, LookIn:=xlValues)
c.Select
End With
Selection.Offset(0, 14).Copy
Windows("FY12-Q3 Value Tracker Key Measure Summary Tables FINAL.xlsm").Activate
Sheets("Store Level Value").Activate
rCell.Select
Selection.Offset(0, 11).Select
Selection.PasteSpecial Paste:=xlPasteValues
Next rCell
End Sub