ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting Multiple columns with multiple rows (https://www.excelbanter.com/excel-programming/441490-selecting-multiple-columns-multiple-rows.html)

BillR

Selecting Multiple columns with multiple rows
 
I am trying to do something like this:
for row=3 to 17
select columns A:F, row
copy selection
select another range on another worksheet
paste what I copied too that range.
next row

I have been able to select one colun at a time, but can't select the whole
range from A to F on the row I am on.
Thanks.
--
BillR

joel[_872_]

Selecting Multiple columns with multiple rows
 

Simple

Range("A3","F17")

Range(range("A3"),range("F17"))

Range(Range("A3"),cells(17,6))

Range(cells(3,1),cells(17,6))


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=194340

http://www.thecodecage.com/forumz


BillR

Selecting Multiple columns with multiple rows
 
I think I mislead you with the description of the problem. On sheet1 I want
to go from rows 3 to 17 one at a time. If cell D on that row is greater than
0, I want to copy A:F and paste it to A2 on sheet2. Then I want to insert a
row on sheet2 to make room for the next copy.
Then go back to sheet1 and use the next row to do it all over again until I
get row 17 copied if D17 is greater than 0.
Thanks for the help.
--
BillR


"joel" wrote:


Simple

Range("A3","F17")

Range(range("A3"),range("F17"))

Range(Range("A3"),cells(17,6))

Range(cells(3,1),cells(17,6))


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=194340

http://www.thecodecage.com/forumz

.


joel[_900_]

Selecting Multiple columns with multiple rows
 

I don't know why you need to add a row on sheet2. I wrote two similar
macros. the 1st doesn't add the row. The 2nd does insert a new row

Destrow = 1
with Sheets("Sheet1")
For RowCount = 3 to 17
Data = .range("D" & rowcount)
if Data 0 then
.Range("A" & RowCount & ":F" & Rowcount).copy _
Destination:=Sheets("Sheet2").range("A" & DestRow)
DestRow = DestRow + 1
End if
Next Rowcount
end with



2nd macro

Destrow = 2
with Sheets("Sheet1")
For RowCount = 3 to 17
Data = .range("D" & rowcount)
if Data 0 then
Sheets("Sheet2").rows(RowCount + 1).Insert
.Range("A" & RowCount & ":F" & Rowcount).copy _
Destination:=Sheets("Sheet2").range("A" & DestRow)
DestRow = DestRow + 1
End if
Next Rowcount
end with
'Original Source: http://tinyurl.com/y84jecl


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=194340

http://www.thecodecage.com/forumz



All times are GMT +1. The time now is 11:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com