Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 3
Default Loops with sheet codenames

I am trying to create a loop in code that does the same commands on multiple worksheets and I want to refer to each sheet using their codename so that it will still work if someone changes the worksheet name on the tab.

Something along these lines.

for p = 2 to 6

name = "sheet" & p

ARow = name.Cells(Rows.Count, "B").End(xlUp).Row

etc

next p

I know that doesn't work so I need help with the code and how to dimension the variables.

To clarify how I would like it to work it should end up doing

ARow = sheet2.Cells(Rows.Count, "B").End(xlUp).Row

when p = 2

Can this be done.

Thanks
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
loops???? harry buggy Excel Worksheet Functions 2 August 14th 07 06:33 PM
Loops SaraJane Excel Discussion (Misc queries) 11 May 26th 07 04:47 AM
Loops... Willabo Excel Discussion (Misc queries) 2 June 14th 06 04:08 PM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy Excel Discussion (Misc queries) 1 June 10th 05 12:17 AM
Using For - Next Loops in VB Biomed New Users to Excel 4 March 22nd 05 07:12 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"