Select Case True question

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,113
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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,216,174
Messages
6,129,296
Members
449,498
Latest member
Lee_ray

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