Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Help creating a proper loop

I would like a user to select rows in a worksheet called "Inventory" (they
will be non-continuous) and then create a For..Next loop (or whatever works
best) based on the rows (or just row number), so I can copy and format select
cells from each row in another worksheet called "Labels". I'm not sure how
to do this, either with an array or by looping thru the rows selected. Also,
I need a check so if nothing has been selected they get an error message.

For the selections, will the user need to select the entire row (1:1, 5:5,
7:7, etc) or if they just ctrl select A1, A5, A7, A11, etc will this work too?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Help creating a proper loop

No need for a loop:

Selection.EntireRow.Copy worksheets("Labels").Range("A2")
Application.CutCopyMode = False

The entire rows need not be selected.
__________________________________________________ _____________________

"Seth" wrote in message
...
I would like a user to select rows in a worksheet called "Inventory" (they
will be non-continuous) and then create a For..Next loop (or whatever
works
best) based on the rows (or just row number), so I can copy and format
select
cells from each row in another worksheet called "Labels". I'm not sure
how
to do this, either with an array or by looping thru the rows selected.
Also,
I need a check so if nothing has been selected they get an error message.

For the selections, will the user need to select the entire row (1:1, 5:5,
7:7, etc) or if they just ctrl select A1, A5, A7, A11, etc will this work
too?

Thanks in advance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Help creating a proper loop

Thanks Vasant, but I don't want to copy all the contents from each row, just
certain cells and then reformat them on a new worksheet.

"Vasant Nanavati" wrote:

No need for a loop:

Selection.EntireRow.Copy worksheets("Labels").Range("A2")
Application.CutCopyMode = False

The entire rows need not be selected.
__________________________________________________ _____________________

"Seth" wrote in message
...
I would like a user to select rows in a worksheet called "Inventory" (they
will be non-continuous) and then create a For..Next loop (or whatever
works
best) based on the rows (or just row number), so I can copy and format
select
cells from each row in another worksheet called "Labels". I'm not sure
how
to do this, either with an array or by looping thru the rows selected.
Also,
I need a check so if nothing has been selected they get an error message.

For the selections, will the user need to select the entire row (1:1, 5:5,
7:7, etc) or if they just ctrl select A1, A5, A7, A11, etc will this work
too?

Thanks in advance!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Help creating a proper loop

I guess I would do the following (assuming the first cell in each relevant
row is selected):

Dim c As Range, rng As Range, newrng As Range
For Each c In Selection.Cells
Set rng = c.Resize(, 5) 'this will encompass the first 5 cells in the
row, for example
If newrng Is Nothing Then
Set newrng = rng
Else
Set newrng = Union(rng, newrng)
End If
Next
newrng.Copy worksheets("Labels").Range("A2")
Application.CutCopyMode = False

Not tested so not 100% sure it will work as you want it to.
__________________________________________________ _______________________





"Seth" wrote in message
...
Thanks Vasant, but I don't want to copy all the contents from each row,
just
certain cells and then reformat them on a new worksheet.

"Vasant Nanavati" wrote:

No need for a loop:

Selection.EntireRow.Copy worksheets("Labels").Range("A2")
Application.CutCopyMode = False

The entire rows need not be selected.
__________________________________________________ _____________________

"Seth" wrote in message
...
I would like a user to select rows in a worksheet called "Inventory"
(they
will be non-continuous) and then create a For..Next loop (or whatever
works
best) based on the rows (or just row number), so I can copy and format
select
cells from each row in another worksheet called "Labels". I'm not sure
how
to do this, either with an array or by looping thru the rows selected.
Also,
I need a check so if nothing has been selected they get an error
message.

For the selections, will the user need to select the entire row (1:1,
5:5,
7:7, etc) or if they just ctrl select A1, A5, A7, A11, etc will this
work
too?

Thanks in advance!






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
creating a loop JakeShipley2008 Excel Discussion (Misc queries) 2 September 9th 08 02:17 PM
Creating a loop JakeShipley2008 Excel Discussion (Misc queries) 1 September 8th 08 10:26 PM
creating a proper text formula Olayah Excel Discussion (Misc queries) 2 May 13th 08 05:54 PM
Need Help With Creating A Loop zero635[_8_] Excel Programming 3 October 29th 05 08:58 PM
Proper Do Loop Construction ChasX Excel Discussion (Misc queries) 6 July 1st 05 10:38 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"