LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How to get my code to loop

Thanks Bob. I was so close.

Dominique
"Bob Phillips" wrote in message
...
Dominique.

Try this

Sub Move()
Dim oCell As Range
Dim sStart As String
With Columns("A:A")
Set oCell = .Find(What:="Diary")
If Not oCell Is Nothing Then
Do
oCell.Copy Destination:=oCell.Offset(0, 4)
oCell.Value = ""
sStart = oCell.Address
Set oCell = .FindNext(oCell)
Loop While Not oCell Is Nothing
End If
End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dominique Feteau" wrote in message
...
This idea works, but not how i need it to work. the reason i used the

.find
method is because "Diary" is the first word in each cell that I want
moved
to the 4th column. for example: in A2 = Diary Date 510, in A45 = Diary

Date
520. I did create a slimmed down version of my macro, but still cant

figure
out how to make it loop.

Sub Move()

Columns("A:A").Select
Cells.Find(What:="Diary", After:=ActiveCell,

LookIn:=xlValues).Activate
Selection.Cut
ActiveCell.Offset(columnOffset:=4).Activate
ActiveSheet.Paste

End Sub

"R.VENKATARAMAN" &&& wrote in message
...
many solutions
your data is A3 to A10
try this macro

Option Explicit

Public Sub test()
Dim cell As Range
For Each cell In Range("a3:a10")
If cell = "dairy" Then cell.Offset(0, 4) = cell
Next
End Sub

the statement after <then can be any action

=======================
Dominique Feteau wrote in message
...
I have a macro that will search Column A for the word "Diary", select
that
cell, and move the contents of that cell over 4 columns. I want it to
look
through the entire column and continue till it doesnt find the word
"diary"
in column A. How do I do that?

Sub Move()

Columns("A:A").Select
Cells.Find(What:="Diary", After:=ActiveCell, LookIn:=xlFormulas,
LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Selection.Cut
ActiveCell.Offset(columnOffset:=4).Activate
ActiveSheet.Paste

End Sub












 
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 code error help!!!! cesaoes Excel Discussion (Misc queries) 2 January 29th 08 04:52 PM
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
Help with loop code... gaba Excel Programming 1 October 20th 04 01:37 PM
VBE code in a loop loloflores Excel Programming 0 April 30th 04 12:28 PM


All times are GMT +1. The time now is 02:03 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"