Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Quotes in VBA Code

I would like to refer to

=range("A10")

similar to the following

=range(""A" & 10")

so that I can increment the number reference. I know I
have the quotes set up wrong. How do you refer to
changing letters or numbers that need to appear within
quotes? Thanks for your help.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Quotes in VBA Code

In a worksheet formula:
=Indirect("A" & 10)

or if B9 will hold the number 10

=Indirect("A" & B9)

------------------

If you mean in code

set rng = Range("A" & 10)

or

lrow = 10
set rng = Range("A" & lRow)



--
Regards,
Tom Ogilvy

"Frank" wrote in message
...
I would like to refer to

=range("A10")

similar to the following

=range(""A" & 10")

so that I can increment the number reference. I know I
have the quotes set up wrong. How do you refer to
changing letters or numbers that need to appear within
quotes? Thanks for your help.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Quotes in VBA Code

Tom,

How do you handle the range reference in code to allow
changing numbers like the following scenario:

With ActiveChart.Parent
.Width = Range("B2:H17").Width
End With

I want to use a loop to add 10 to the reference above to
get something like:

With ActiveChart.Parent
.Width = Range("B12:H27").Width
End With

The outside quotes have me confused. Thanks again for your
help.

-----Original Message-----
In a worksheet formula:
=Indirect("A" & 10)

or if B9 will hold the number 10

=Indirect("A" & B9)

------------------

If you mean in code

set rng = Range("A" & 10)

or

lrow = 10
set rng = Range("A" & lRow)



--
Regards,
Tom Ogilvy

"Frank" wrote in

message
...
I would like to refer to

=range("A10")

similar to the following

=range(""A" & 10")

so that I can increment the number reference. I know I
have the quotes set up wrong. How do you refer to
changing letters or numbers that need to appear within
quotes? Thanks for your help.



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Quotes in VBA Code

With ActiveChart.Parent
.Width = Range("B2:H" & myRow + 10).Width
End With

--

HTH

RP

"Frank" wrote in message
...
Tom,

How do you handle the range reference in code to allow
changing numbers like the following scenario:

With ActiveChart.Parent
.Width = Range("B2:H17").Width
End With

I want to use a loop to add 10 to the reference above to
get something like:

With ActiveChart.Parent
.Width = Range("B12:H27").Width
End With

The outside quotes have me confused. Thanks again for your
help.

-----Original Message-----
In a worksheet formula:
=Indirect("A" & 10)

or if B9 will hold the number 10

=Indirect("A" & B9)

------------------

If you mean in code

set rng = Range("A" & 10)

or

lrow = 10
set rng = Range("A" & lRow)



--
Regards,
Tom Ogilvy

"Frank" wrote in

message
...
I would like to refer to

=range("A10")

similar to the following

=range(""A" & 10")

so that I can increment the number reference. I know I
have the quotes set up wrong. How do you refer to
changing letters or numbers that need to appear within
quotes? Thanks for your help.



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Quotes in VBA Code

for i = 0 to 3
With Activechart.Parent
.width = Range("B2:H17").Offset(10*i,0).Width
End With
Next

But since you are always looking at Columns B:H, the width should be the
same.

But just to illustrate:

Sub Tester8()
For i = 0 To 3
' With ActiveChart.Parent
Debug.Print i, Range("B2:H17") _
.Offset(10 * i, 0).Address
' End With
Next

End Sub

Produces:

0 $B$2:$H$17
1 $B$12:$H$27
2 $B$22:$H$37
3 $B$32:$H$47

--
Regards,
Tom Ogilvy

"Frank" wrote in message
...
Tom,

How do you handle the range reference in code to allow
changing numbers like the following scenario:

With ActiveChart.Parent
.Width = Range("B2:H17").Width
End With

I want to use a loop to add 10 to the reference above to
get something like:

With ActiveChart.Parent
.Width = Range("B12:H27").Width
End With

The outside quotes have me confused. Thanks again for your
help.

-----Original Message-----
In a worksheet formula:
=Indirect("A" & 10)

or if B9 will hold the number 10

=Indirect("A" & B9)

------------------

If you mean in code

set rng = Range("A" & 10)

or

lrow = 10
set rng = Range("A" & lRow)



--
Regards,
Tom Ogilvy

"Frank" wrote in

message
...
I would like to refer to

=range("A10")

similar to the following

=range(""A" & 10")

so that I can increment the number reference. I know I
have the quotes set up wrong. How do you refer to
changing letters or numbers that need to appear within
quotes? Thanks for your help.



.



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
change straight quotes to curly quotes callico Excel Discussion (Misc queries) 2 June 22nd 07 10:23 PM
How do i get historical stock quotes using MSN Money Stock Quotes Ash Excel Discussion (Misc queries) 0 May 11th 06 03:26 AM
Using CSV and quotes Neil Excel Discussion (Misc queries) 4 October 31st 05 07:59 PM
Code to create Email that includes quotes Jeremy Gollehon[_2_] Excel Programming 4 May 12th 04 06:53 PM
Quotes PastorMike Excel Programming 1 May 4th 04 03:58 PM


All times are GMT +1. The time now is 08:23 PM.

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"