ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VB question (https://www.excelbanter.com/excel-discussion-misc-queries/169611-vbulletin-question.html)

mohavv

VB question
 
Hi,

Why do I get an error:

Sht = Sheets("print").Range("D" & a).Value

Sheets(Sht).Range("Print_Area" & Sht).Select

but when I cut it in 2 it works:

Sht = Sheets("print").Range("D" & a).Value

Sheets(Sht).Select
Range("Print_Area" & Sht).Select

Cheers,

Harold

JP[_4_]

VB question
 
You have to provide more context.

Is "Sht" a declared variable? If so, as what?
What is "a" ?


Thx,
JP


On Dec 13, 3:53 pm, mohavv wrote:
Hi,

Why do I get an error:

Sht = Sheets("print").Range("D" & a).Value

Sheets(Sht).Range("Print_Area" & Sht).Select

but when I cut it in 2 it works:

Sht = Sheets("print").Range("D" & a).Value

Sheets(Sht).Select
Range("Print_Area" & Sht).Select

Cheers,

Harold



Bob Phillips

VB question
 
Because you have to activate a sheet before you can select a range on that
sheet.

But you shouldn't need to select anything. What are you trying to do?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"mohavv" wrote in message
...
Hi,

Why do I get an error:

Sht = Sheets("print").Range("D" & a).Value

Sheets(Sht).Range("Print_Area" & Sht).Select

but when I cut it in 2 it works:

Sht = Sheets("print").Range("D" & a).Value

Sheets(Sht).Select
Range("Print_Area" & Sht).Select

Cheers,

Harold





All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com