vulcanfury
New Member
- Joined
- Sep 15, 2014
- Messages
- 29
Hi all,
I'm having trouble making this loop iterate:
Basically, it copies some of the values in the columns in one sheet (Detail_Sheet), then pastes those values one by one in rows to another sheet (Summary). It's similar to transposing a column.
What I want to do is to ensure that this keeps happening until I encounter a blank column in Detail_Sheet. I try and I try and I try but it just keeps going over the loop once. I tried using a For loop, just to see if I can make it print multiple rows, and it does, but to do what I want, I need to do a Do-While Loop. Please help!
EDIT:
I figured it out. It seems all I needed to do was to select Detail_Sheet again at the end of the loop.
I'm having trouble making this loop iterate:
Code:
Do While Cells(96, DtlNxtCol + 2).Value > 0
Sheets("Detail_Sheet").Select
Cells(10, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail_Sheet").Select
Cells(5, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail_Sheet").Select
Cells(6, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 3).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail_Sheet").Select
Cells(7, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 4).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail_Sheet").Select
Cells(8, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail_Sheet").Select
Cells(9, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 6).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail_Sheet").Select
Cells(96, DtlNxtCol).Copy
Sheets("Summary").Select
Cells(SumNxtRow, 7).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
DtlNxtCol = DtlNxtCol + 2
SumNxtRow = SumNxtRow + 1
Loop
Basically, it copies some of the values in the columns in one sheet (Detail_Sheet), then pastes those values one by one in rows to another sheet (Summary). It's similar to transposing a column.
What I want to do is to ensure that this keeps happening until I encounter a blank column in Detail_Sheet. I try and I try and I try but it just keeps going over the loop once. I tried using a For loop, just to see if I can make it print multiple rows, and it does, but to do what I want, I need to do a Do-While Loop. Please help!
EDIT:
I figured it out. It seems all I needed to do was to select Detail_Sheet again at the end of the loop.
Last edited: