vba refer previous sheet not by name

grapevine

Board Regular
Joined
May 23, 2007
Messages
208
I have the following code which works correctly, but I will need to replicate it and alter it slightly 15 times to refer to different pages. Is it possible to alter this code so that it looks at the previous sheet to the one that I am on. My actual spreadsheet consists of 5 core pages and I need to extract information from those pages onto 15 other sheets. The call routines will be very similar and where possible I want to store routine tasks in sub routines that I can easily call when needed. This coding refers to column on sheet 7 which is obtaining information from sheet 6. later I will be creating sheets 8 and 9 and will need to lookup data on sheet 8 that needs to be placed into sheet 9. I hope this makes sense.

I have copied the full code below for information but the key element that need adapting is

VLOOKUP(RC[-14],'W & G List'!R1C13:R22C14,2,FALSE

I would be grateful fo any assistance is how I could adapt this.
Kind regards
Marion

full code for information is
Sub preparelabels()
Dim rw As Long
rw = Range("c65536").End(xlUp).row
Range("R1") = "Code"
Range("R2:r" & rw).FormulaR1C1 = "=if(iserror(VLOOKUP(RC[-14],'W & G List'!R1C13:R22C14,2,FALSE)),"""",vLOOKUP(RC[-14],'W & G List'!R1C13:R22C14,2,FALSE))"
End Sub
 
Can you post your full code with the functions implemented? I am new to VBA and having a tough time visualizing all of this. Thanks in advance!
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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