Select Case True question

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm working on a sub to apply it on a workbook with 26 worksheets in it.



So how do I use
Code:
Select Case True
to say something like ...

If active curser is on worksheet 26 then
Code:
Case Worksheet(26)
then
Code:
.Subject = Worksheets(26).Range("O18").Value   .Display

So on, if active curser is on worksheet 24 then
Code:
Case Worksheet(24)
then
Code:
.Subject = Worksheets(24).Range("O18").Value   .Display


Does anyone see where I'm going with this?

Many thanks for your help.

Respectfully,
Pinaceous
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Is Worksheet(26) the tab name of the sheet or did you mean Worksheets(26) where 26 is the sheet index (26th sheet from the left-most sheet on the sheets tab of the workbook)? If you are referring to a sheet index try:
Code:
Select Case Activesheet.Index
Case 26
'rest of code
End Select
 
Upvote 0
Is Worksheet(26) the tab name of the sheet or did you mean Worksheets(26) where 26 is the sheet index (26th sheet from the left-most sheet on the sheets tab of the workbook)?]


Hello Joe!

This is correct.

Whereby if I'm actively on Worksheet(24) it will select that case.

I am getting a VBA compile error when using the code.
Code:
Case without Select Case

Can you help me with this?

Thank you!
Paul
 
Upvote 0
Hi Joe,

I'm sorry, I've got it to work.

Don't worry about it!

Your code worked perfect.

Thanks again!
Paul
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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