#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 897
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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



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
sum if question Ann Excel Worksheet Functions 6 June 28th 07 09:00 PM
Look up question Graham944 Excel Worksheet Functions 1 December 5th 06 07:00 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
VBA Question Phil Osman Excel Discussion (Misc queries) 5 April 19th 05 02:04 AM


All times are GMT +1. The time now is 12:40 AM.

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"