Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Use R1C1 to select cell

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Use R1C1 to select cell

Try this, works on the active worksheet.

Sub randomnums()
myvalue = Int((8 * Rnd) + 1)
Cells(1, myvalue).Select
End Sub

Mike

"JimK" wrote:

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Use R1C1 to select cell

Thank you Mike. That worked. Do you know how to identify the row number of
the active cell? I've been trying, but the ROW command seems to escape me.

"Mike" wrote:

Try this, works on the active worksheet.

Sub randomnums()
myvalue = Int((8 * Rnd) + 1)
Cells(1, myvalue).Select
End Sub

Mike

"JimK" wrote:

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Use R1C1 to select cell

The following line in the macro wilol return the coilm letter

ColumnLetter = Chr(myvalue + 64)

Mike

"JimK" wrote:

Thank you Mike. That worked. Do you know how to identify the row number of
the active cell? I've been trying, but the ROW command seems to escape me.

"Mike" wrote:

Try this, works on the active worksheet.

Sub randomnums()
myvalue = Int((8 * Rnd) + 1)
Cells(1, myvalue).Select
End Sub

Mike

"JimK" wrote:

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Use R1C1 to select cell

Sorry, I mesread you second question. The row number will always be 1 because
that's what the macro does it selects a random column between 1 & 8 and then
selects the cell in row 1 of that column.

Mike

"JimK" wrote:

Thank you Mike. That worked. Do you know how to identify the row number of
the active cell? I've been trying, but the ROW command seems to escape me.

"Mike" wrote:

Try this, works on the active worksheet.

Sub randomnums()
myvalue = Int((8 * Rnd) + 1)
Cells(1, myvalue).Select
End Sub

Mike

"JimK" wrote:

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Use R1C1 to select cell

Sorry, I should have clarified: this is a question for a different part of
the macro. If I have an active cell, how do I identify what the row is for
that active cell (unrelated to the question you already helped me with).
Thanks.

"Mike" wrote:

Sorry, I mesread you second question. The row number will always be 1 because
that's what the macro does it selects a random column between 1 & 8 and then
selects the cell in row 1 of that column.

Mike

"JimK" wrote:

Thank you Mike. That worked. Do you know how to identify the row number of
the active cell? I've been trying, but the ROW command seems to escape me.

"Mike" wrote:

Try this, works on the active worksheet.

Sub randomnums()
myvalue = Int((8 * Rnd) + 1)
Cells(1, myvalue).Select
End Sub

Mike

"JimK" wrote:

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Use R1C1 to select cell

msgbox activecell.row



JimK wrote:

Sorry, I should have clarified: this is a question for a different part of
the macro. If I have an active cell, how do I identify what the row is for
that active cell (unrelated to the question you already helped me with).
Thanks.

"Mike" wrote:

Sorry, I mesread you second question. The row number will always be 1 because
that's what the macro does it selects a random column between 1 & 8 and then
selects the cell in row 1 of that column.

Mike

"JimK" wrote:

Thank you Mike. That worked. Do you know how to identify the row number of
the active cell? I've been trying, but the ROW command seems to escape me.

"Mike" wrote:

Try this, works on the active worksheet.

Sub randomnums()
myvalue = Int((8 * Rnd) + 1)
Cells(1, myvalue).Select
End Sub

Mike

"JimK" wrote:

Hi, I'm trying to program my macro to:
Chose a random number between 1 and 8, then identify the column in my
worksheet that corresponds to that random number (i.e. 4 = column D), then
select the cell in Row 1 in that column.
Any help would be greatly appreciated. Thanks.


--

Dave Peterson
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
refer to a particular cell in r1c1 style John Smith Excel Programming 11 November 19th 06 03:01 AM
Using R1C1 in VB to select a range Robert_L_Ross Excel Programming 2 December 17th 05 07:45 AM
Using a cell value for row in R1C1 Rob T Excel Worksheet Functions 2 November 2nd 05 03:47 PM
Select Range using R1C1 verizon Excel Programming 4 June 16th 04 01:11 PM
Getting the value from a cell, and then using it as a name or R1C1 reference Art Excel Programming 1 April 30th 04 07:48 AM


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