VBA combining Select & Range Select statements

Pinaceous

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

I'm working with the following code:

Code:
Sub Macro11()
'
'
'

    Worksheets("REPORT").Select
    
    Worksheets("REPORT").Range("A1:L47").Select
    


End Sub

Does anyone know how to combine these terms so I have one line?

For example, I've tried variations of this code below, but I'm way off and need some help.

Code:
Sub Macro11()
'
'
'
    Dim ws As Worksheet

    For Each ws In Worksheets

     If ws.Name("REPORT") Then
    
        Range("A1:L47").Select
    
    Next ws
    
End If

End Sub




Thank you!
Pinaceous
 

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't really combine them, if 'REPORT' isn't the active sheet you can't select a range on it so you need to select the sheet first.

What are you going to be doing with the selected range on 'REPORT'?
 
Upvote 0
Hi Norie,

I was hoping to run the sub where it selects the sheet than range by itself.

If for example, not being on that active sheet but it taking me there.

Afterwards, I'm going to 'Call' a Pdf sub that I have to produce the actual report.

I have 12 report tabs and wanted to see if there was an easier way to express this type of function.

Thanks for responding!
Pinaceous
 
Upvote 0
Perhaps you could use Application.Goto?
Code:
Application.Goto Worksheets("REPORT").Range("A1:L47"), True
 
Upvote 0
Hell Norie!

As you can tell by the exclamation mark, that did it!

Thank you very much for your input!

Pinaceous
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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