Naming a sheet and using in formula

EmyrPC

New Member
Joined
Jan 12, 2018
Messages
9
Hey everyone,

I've created and named a sheet based on a list in another sheet. Which works great:

Dim WB As Workbook
Set WB = Workbooks("Workbook")
Dim List As Worksheet
Set List = WB.Sheets("Sheet1")
Dim r As Integer
Dim Last_Row As Integer
Last_Row = Application.WorksheetFunction.CountA(List.Range("A:A"))
'Start Loop
For r = 2 To Last_Row

WB.Sheets.Add
WB.ActiveSheet.Name = List.Range("A" & r).Value & "AE"
Dim AES As Worksheet
Set AES = WB.Sheets(List.Range("A" & r).Value & "AE")

The problem I have is now referencing the sheet in a formula (vlookup/countif etc)

Code:
.Formula = "=VLOOKUP(BJ6,' [I][B]WHAT CAN I PUT HERE[/B][/I] '!L:AB,17,FALSE)"

Can anyone help please?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You can assign the sheet to a variable then use that. For example:

Code:
Set sh = wb.Sheets.Add
'more code
.Formula = "=VLOOKUP(BJ6,'" & sh.Name & "'!L:AB,17,FALSE)"
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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