Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Help with loop code...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with loop code...

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
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
Loop for VBA code? paulinoluciano Excel Worksheet Functions 5 December 28th 05 01:30 PM
How to Loop some code Phil Osman Excel Discussion (Misc queries) 2 August 19th 05 11:14 AM
VBA Newbie: Help with Do Loop code Carl Excel Discussion (Misc queries) 3 December 2nd 04 07:04 PM
VBE code in a loop loloflores Excel Programming 0 April 30th 04 12:28 PM
Loop code problems pauluk[_51_] Excel Programming 2 April 23rd 04 10:30 AM


All times are GMT +1. The time now is 09:40 PM.

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"