Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've been stuck with this loop for few days, please if somebody can see
what's wrong with my code... I'm trying to create a loop for a range of rows, find certain value, insert a column if there is a match and copy cells to that new column, if not a match go to next So far I have Sub InsertColumns () Sheets("data").Range("G15").Select 'I need to check row 15 to end Do If ActiveCell.Offset(0, 0).Value = "QC Std 2" Then ActiveCell.Offset(0, 0).Select Selection.EntireColumn.Offset(0, 1).Insert 'Range("H78", "H88").Copy Destination:=ActiveCell.Offset(-7, 0) ElseIf ActiveCell.Offset(0, 0).Value = "QC Std 3" Then ActiveCell.Offset(0, 0).Select Selection.EntireColumn.Offset(0, 1).Insert Else 'do nothing, go to next End If ActiveCell.Offset(0, 1).Select Loop Until IsEmpty(ActiveCell.Offset(0, 0)) End Sub Any help will be more than appreciated! -- gaba :) -- gaba :) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub InsertColumns()
Sheets("data").Activate Cells(15, "IV").End(xlToLeft).Select 'I need to check row 15 to end Do If ActiveCell.Value = "QC Std 2" Then ActiveCell.Offset(0, 1).EntireColumn.Insert Range("H78:H88").Copy _ Destination:=ActiveCell.Offset(-7, 1) ElseIf ActiveCell.Value = "QC Std 3" Then ActiveCell.Offset(0, 1).EntireColumn.Insert End If ActiveCell.Offset(0, -1).Select Loop Until ActiveCell.Address = "$F$15" End Sub -- Regards, Tom Ogilvy "gaba" wrote in message ... I've been stuck with this loop for few days, please if somebody can see what's wrong with my code... I'm trying to create a loop for a range of rows, find certain value, insert a column if there is a match and copy cells to that new column, if not a match go to next So far I have Sub InsertColumns () Sheets("data").Range("G15").Select 'I need to check row 15 to end Do If ActiveCell.Offset(0, 0).Value = "QC Std 2" Then ActiveCell.Offset(0, 0).Select Selection.EntireColumn.Offset(0, 1).Insert 'Range("H78", "H88").Copy Destination:=ActiveCell.Offset(-7, 0) ElseIf ActiveCell.Offset(0, 0).Value = "QC Std 3" Then ActiveCell.Offset(0, 0).Select Selection.EntireColumn.Offset(0, 1).Insert Else 'do nothing, go to next End If ActiveCell.Offset(0, 1).Select Loop Until IsEmpty(ActiveCell.Offset(0, 0)) End Sub Any help will be more than appreciated! -- gaba :) -- gaba :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop for VBA code? | Excel Worksheet Functions | |||
How to Loop some code | Excel Discussion (Misc queries) | |||
VBA Newbie: Help with Do Loop code | Excel Discussion (Misc queries) | |||
VBE code in a loop | Excel Programming | |||
Loop code problems | Excel Programming |