loop to look up value in column a cant start on sheet number 2

jacinthn

Board Regular
Joined
Jun 15, 2010
Messages
96
im having trouble with this loop i want this macro to look up the values in column a and return the coresponding values from column G of the match sheet to column f of my current worksheet then loop that through all the sheets in the workbook but do it for all the values in column A not just 1
i keep getting an error on 2 to sheets.count type mismatch... i dont know how to fix this :( help ??


For wbs = 2 To Sheets.Count
For Each wbs In ActiveWorkbook.Worksheets
wbs.Activate
y = 3
x = 2
Do
x = x + 1
If Range("A3") = ActiveWorkbook.Sheets("MASTER").Range("A" & x) Then
Range("F" & y) = ActiveWorkbook.Sheets("MASTER").Range("G" & x).Value
y = y + 1
End If
Loop Until x = 3000
Next sht
Next
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You were close... I didn't check the rest of the code but the below change will get you past the type mismatch error you were receiving.

im having trouble with this loop i want this macro to look up the values in column a and return the coresponding values from column G of the match sheet to column f of my current worksheet then loop that through all the sheets in the workbook but do it for all the values in column A not just 1
i keep getting an error on 2 to sheets.count type mismatch... i dont know how to fix this :( help ??


For wbs = 2 To WorkSheets.Count
For Each wbs In ActiveWorkbook.Worksheets
wbs.Activate
y = 3
x = 2
Do
x = x + 1
If Range("A3") = ActiveWorkbook.Sheets("MASTER").Range("A" & x) Then
Range("F" & y) = ActiveWorkbook.Sheets("MASTER").Range("G" & x).Value
y = y + 1
End If
Loop Until x = 3000
Next sht
Next
 
Upvote 0
im having trouble with this loop i want this macro to look up the values in column a and return the coresponding values from column G of the match sheet to column f of my current worksheet then loop that through all the sheets in the workbook but do it for all the values in column A not just 1
i keep getting an error on 2 to sheets.count type mismatch... i dont know how to fix this :( help ??


For wbs = 2 To Sheets.Count
For Each wbs In ActiveWorkbook.Worksheets
wbs.Activate
y = 3
x = 2
Do
x = x + 1
If Range("A3") = ActiveWorkbook.Sheets("MASTER").Range("A" & x) Then
Range("F" & y) = ActiveWorkbook.Sheets("MASTER").Range("G" & x).Value
y = y + 1
End If
Loop Until x = 3000
Next sht
Next



Try this change:

For x = 2 To Worksheets.Count
Worksheets(x).Activate

y = 3
x = 2

Do
x = x + 1
If Range("A3") = ActiveWorkbook.Sheets("MASTER").Range("A" & x) Then
Range("F" & y) = ActiveWorkbook.Sheets("MASTER").Range("G" & x).Value
y = y + 1
End If
Loop Until x = 3000

Next
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,310
Members
452,906
Latest member
phanmemchatdakenhupviral

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top