Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multiple Cells

Hello. I have a sub that iterates over some cells in my worksheet. So
something like this:

CurRow=1
Do While (CurRow <= 1000)
CurCol = 1
Do While (CurCol <=1000)
Worksheet.Cells(CurRow, 1) .Value = ComputeValue(CurRow, CurCol)
CurCol = CurCol + 1
Loop
CurRow = CurRow + 1
Loop

I want to select some of those cells during the iteration, but don't
have good way to select a range. For instance I want to be able to do
something like:

Worksheets.Range(CurCol & CurRow & ":" & CurCol + 37 & CurRow +
29).Select

But that that wouldn't work because CurCol is a numeric value not the A
B C ... value that Range expects.

Any idea?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Multiple Cells

Hi,
Addendum, meant to include in the previous post.

Worksheet.Cells . . . . . . . won't work
If it's the activesheet you can use
Activesheet.Cells . . . . . . . if you want.

Don


"Kramer" wrote in message
oups.com...
Hello. I have a sub that iterates over some cells in my worksheet. So
something like this:

CurRow=1
Do While (CurRow <= 1000)
CurCol = 1
Do While (CurCol <=1000)
Worksheet.Cells(CurRow, 1) .Value = ComputeValue(CurRow, CurCol)
CurCol = CurCol + 1
Loop
CurRow = CurRow + 1
Loop

I want to select some of those cells during the iteration, but don't
have good way to select a range. For instance I want to be able to do
something like:

Worksheets.Range(CurCol & CurRow & ":" & CurCol + 37 & CurRow +
29).Select

But that that wouldn't work because CurCol is a numeric value not the A
B C ... value that Range expects.

Any idea?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multiple Cells

I wasn;t really asking about how to refer to a Worksheet. I guess that
I did post it wrong. What I meant to say was this:

OutWorksheet = Worksheets("some name")
CurRow=1
Do While (CurRow <= 1000)
CurCol = 1
Do While (CurCol <=1000)
OutWorksheet.Cells(CurRow, 1) .Value = ComputeValue(CurRow,
CurCol)
CurCol = CurCol + 1
Loop
CurRow = CurRow + 1
Loop

I want to select some of those cells during the iteration, but don't
have good way to select a range. For instance I want to be able to do
something like:
OutWorksheet.Range(CurCol & CurRow & ":" & CurCol + 37 & CurRow +
29).Select

So basically, I'm looking for a way to build a range object given
numerical indices CurCol and CurRow. Any help?


Don Lloyd wrote:
Hi,
Addendum, meant to include in the previous post.

Worksheet.Cells . . . . . . . won't work
If it's the activesheet you can use
Activesheet.Cells . . . . . . . if you want.

Don


"Kramer" wrote in message
oups.com...
Hello. I have a sub that iterates over some cells in my worksheet. So
something like this:







But that that wouldn't work because CurCol is a numeric value not the A
B C ... value that Range expects.

Any idea?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multiple Cells

First, if you're using xl2003 or below, you don't have 1000 columns in your
worksheet.

and you can do stuff like:

with worksheets("sheetnamehere")
.select
.range(.cells(currow,curcol),.cells(currow+29,curc ol+37)).select
end with

Or you could use .Resize()

with worksheets("sheetnamehere")
.select
.cells(currow,curcol).resize(29+1,37+1).select
'or
.cells(currow,curcol).resize(30,38).select
end with

Remember, you have to be on the active sheet to do .select's.

Kramer wrote:

Hello. I have a sub that iterates over some cells in my worksheet. So
something like this:

CurRow=1
Do While (CurRow <= 1000)
CurCol = 1
Do While (CurCol <=1000)
Worksheet.Cells(CurRow, 1) .Value = ComputeValue(CurRow, CurCol)
CurCol = CurCol + 1
Loop
CurRow = CurRow + 1
Loop

I want to select some of those cells during the iteration, but don't
have good way to select a range. For instance I want to be able to do
something like:

Worksheets.Range(CurCol & CurRow & ":" & CurCol + 37 & CurRow +
29).Select

But that that wouldn't work because CurCol is a numeric value not the A
B C ... value that Range expects.

Any idea?


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multiple Cells

Thanks a lot.

I guess that I don't have 1000 cols (it was just an example), but I do
have a lot.

Thanks again.

Dave Peterson wrote:
First, if you're using xl2003 or below, you don't have 1000 columns in your
worksheet.

and you can do stuff like:

with worksheets("sheetnamehere")
.select
.range(.cells(currow,curcol),.cells(currow+29,curc ol+37)).select
end with

Or you could use .Resize()

with worksheets("sheetnamehere")
.select
.cells(currow,curcol).resize(29+1,37+1).select
'or
.cells(currow,curcol).resize(30,38).select
end with

Remember, you have to be on the active sheet to do .select's.

Kramer wrote:

Hello. I have a sub that iterates over some cells in my worksheet. So
something like this:

CurRow=1
Do While (CurRow <= 1000)
CurCol = 1
Do While (CurCol <=1000)
Worksheet.Cells(CurRow, 1) .Value = ComputeValue(CurRow, CurCol)
CurCol = CurCol + 1
Loop
CurRow = CurRow + 1
Loop

I want to select some of those cells during the iteration, but don't
have good way to select a range. For instance I want to be able to do
something like:

Worksheets.Range(CurCol & CurRow & ":" & CurCol + 37 & CurRow +
29).Select

But that that wouldn't work because CurCol is a numeric value not the A
B C ... value that Range expects.

Any idea?


--

Dave Peterson




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Multiple Cells

I assume you didn't see my first post !
Don

"Kramer" wrote in message
oups.com...
I wasn;t really asking about how to refer to a Worksheet. I guess that
I did post it wrong. What I meant to say was this:

OutWorksheet = Worksheets("some name")
CurRow=1
Do While (CurRow <= 1000)
CurCol = 1
Do While (CurCol <=1000)
OutWorksheet.Cells(CurRow, 1) .Value = ComputeValue(CurRow,
CurCol)
CurCol = CurCol + 1
Loop
CurRow = CurRow + 1
Loop

I want to select some of those cells during the iteration, but don't
have good way to select a range. For instance I want to be able to do
something like:
OutWorksheet.Range(CurCol & CurRow & ":" & CurCol + 37 & CurRow +
29).Select

So basically, I'm looking for a way to build a range object given
numerical indices CurCol and CurRow. Any help?


Don Lloyd wrote:
Hi,
Addendum, meant to include in the previous post.

Worksheet.Cells . . . . . . . won't work
If it's the activesheet you can use
Activesheet.Cells . . . . . . . if you want.

Don


"Kramer" wrote in message
oups.com...
Hello. I have a sub that iterates over some cells in my worksheet. So
something like this:







But that that wouldn't work because CurCol is a numeric value not the A
B C ... value that Range expects.

Any idea?




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
Select multiple adjacent cells of multiple cells without selecting sjsjsjsjsjs New Users to Excel 11 December 24th 09 01:09 AM
Select multiple adjacent cells of multiple cells without selecting sjsjsjsjsjs Excel Worksheet Functions 7 December 23rd 09 08:54 PM
macro copy/paste data from multiple cells to multiple cells Diana Excel Discussion (Misc queries) 0 July 10th 06 09:24 PM
Date and time stamping multiple cells for multiple entries. Gerald Excel Worksheet Functions 1 May 9th 06 01:45 PM
make multiple cells in 1 worksheet equal multiple cells in another riley454 Excel Worksheet Functions 1 January 19th 06 03:00 PM


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