Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Another syntax question (different from earlier post)

All:

Another general question about syntax. This one deals with .Range vs .Cells.

I know that .Cells will accept two variables, e.g. mySheet.Cells(myRow,
myCol).

Can .Range do the same? If so, how would I write a .Range to accept a
variable for the column AND and both the column and the row? can this be
done? See below.

Thanks,
MARTY

mySheet.Range("A" & myRow) 'I know this works OK.

'Problem 1
'varying the column designation with a constant row

mySheet.Range(myCol & "1") 'this doesn't work I don't believe, even when
myRow is a capital letter.

'Problem 2
'varying both the colum and the row
mySheet.Range(myCol & myRow) 'I know this doesn't work even when myRow is a
capital letter and myRow is a positive integer. I think I need some double
quotes but I don't know where.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Another syntax question (different from earlier post)

CORRECTION: In the two "problems" after my display name, I meant to say the
following:
Problem 1: ...even when myCol is a capital letter

Problem 2: ...even when myCol is a capital letter and myRow is a positive
integer.

Sorry for the confusion.

MARTY

"Marty" wrote:

All:

Another general question about syntax. This one deals with .Range vs .Cells.

I know that .Cells will accept two variables, e.g. mySheet.Cells(myRow,
myCol).

Can .Range do the same? If so, how would I write a .Range to accept a
variable for the column AND and both the column and the row? can this be
done? See below.

Thanks,
MARTY

mySheet.Range("A" & myRow) 'I know this works OK.

'Problem 1
'varying the column designation with a constant row

mySheet.Range(myCol & "1") 'this doesn't work I don't believe, even when
myRow is a capital letter.

'Problem 2
'varying both the colum and the row
mySheet.Range(myCol & myRow) 'I know this doesn't work even when myRow is a
capital letter and myRow is a positive integer. I think I need some double
quotes but I don't know where.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Another syntax question (different from earlier post)

Set MySheet = Activesheet
mycol = "A"
myRow = 1
msgbox MySheet.Range(mycol & myrow).Address

works fine. For RANGE, myCol must be letters, not numbers.

Also

Set MySheet = Activesheet
mycol = "A"
myRow = 1
mycol1 = "Z
myRow1 = 26
msgbox MySheet.Range(mycol & myrow & ":" & myCol1 & myrow1).Address

will work.


If you want numbers only, why not use CELLS

--
Regards,
Tom Ogilvy

"Marty" wrote in message
...
All:

Another general question about syntax. This one deals with .Range vs

..Cells.

I know that .Cells will accept two variables, e.g. mySheet.Cells(myRow,
myCol).

Can .Range do the same? If so, how would I write a .Range to accept a
variable for the column AND and both the column and the row? can this be
done? See below.

Thanks,
MARTY

mySheet.Range("A" & myRow) 'I know this works OK.

'Problem 1
'varying the column designation with a constant row

mySheet.Range(myCol & "1") 'this doesn't work I don't believe, even when
myRow is a capital letter.

'Problem 2
'varying both the colum and the row
mySheet.Range(myCol & myRow) 'I know this doesn't work even when myRow is

a
capital letter and myRow is a positive integer. I think I need some

double
quotes but I don't know where.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Another syntax question (different from earlier post)

I see my problem now. I was missing the ":" separator.

Thanks for the great help as usual, Tom.

"Tom Ogilvy" wrote:

Set MySheet = Activesheet
mycol = "A"
myRow = 1
msgbox MySheet.Range(mycol & myrow).Address

works fine. For RANGE, myCol must be letters, not numbers.

Also

Set MySheet = Activesheet
mycol = "A"
myRow = 1
mycol1 = "Z
myRow1 = 26
msgbox MySheet.Range(mycol & myrow & ":" & myCol1 & myrow1).Address

will work.


If you want numbers only, why not use CELLS

--
Regards,
Tom Ogilvy

"Marty" wrote in message
...
All:

Another general question about syntax. This one deals with .Range vs

..Cells.

I know that .Cells will accept two variables, e.g. mySheet.Cells(myRow,
myCol).

Can .Range do the same? If so, how would I write a .Range to accept a
variable for the column AND and both the column and the row? can this be
done? See below.

Thanks,
MARTY

mySheet.Range("A" & myRow) 'I know this works OK.

'Problem 1
'varying the column designation with a constant row

mySheet.Range(myCol & "1") 'this doesn't work I don't believe, even when
myRow is a capital letter.

'Problem 2
'varying both the colum and the row
mySheet.Range(myCol & myRow) 'I know this doesn't work even when myRow is

a
capital letter and myRow is a positive integer. I think I need some

double
quotes but I don't know where.





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
Ref earlier post "Excel Time Calculation" jc Excel Discussion (Misc queries) 4 November 7th 07 08:32 PM
Solver Problem ( related to earlier post of using if an Vlookup) Honey Excel Worksheet Functions 1 April 19th 07 11:16 PM
disregard earlier post Jenny B. Excel Discussion (Misc queries) 2 March 22nd 07 06:11 PM
Chart Class Module/follow on question to hyperlink post earlier. Rominall Charts and Charting in Excel 2 March 7th 07 02:43 AM
Previous Post - Correct Syntax Query Clarence Crow Excel Worksheet Functions 0 December 7th 04 05:35 AM


All times are GMT +1. The time now is 11:45 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"