LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default do while loop

Saravanan, Here is code I found to work. Sorry I am late with this; if you
already found an answer, that's ok. You will see that I had to declare the
variable c...you probably already handle that elsewhere, and that
firstaddress was not needed. This macro MUST run from the "download_data"
sheet since the output sheet won't find "Text39:" string. Workbook was
received in Outline mode which made c=Nothing early in the process. Also,
your code was testing 500 rows in Column D (there is no Text39: in this
column). If your actual workbook looks like the one you sent to me, run the
..Find on the entire Column M. Then extrapolate this from the "download_data"
worksheet to the output sheet you are creating. Hope this helps.

Sub saravanan()

With Worksheets(1).Range("M:M")
Set c = .Find("Text39:", LookIn:=xlValues)
Do
c.Activate
' Check that we don't have a bad error that needs to be handled
If Err.Number = 0 Then
ActiveCell.Offset(0, -4).Value = c.Cells(-1, -3).Value
ActiveCell.Offset(0, -3).Value = c.Cells(-1, -2).Value
c.Value = ActiveCell.Offset(0, 1).Value
Set c = .FindNext(c)
Else
'Saravanan, create an error handler if you don't have one elsewhere
MsgBox "Deal with error " & Err.Number & ": " & Err.Description
End If
Loop Until c Is Nothing
End With

--
--Being powerful is like being a lady; if you have to tell people you are,
you aren''t. ~~Margaret Thatcher


"saravanan" wrote:

Hi Mary

I have writen a macro

which is not working properly

With Worksheets(1).Range("d1:d500")
Set c = .Find("text39:", LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Address
Do
Set c = ActiveCell
Selection.Delete Shift:=xlToLeft
'c.Activate
ActiveSheet.Cells(c.Row, 3).Select
MsgBox (c.Value)
ActiveCell.FormulaR1C1 = "=R[-1]C"
Set c = .FindNext(c)
c.Activate
Loop While Not c Is Nothing And c.Address < firstaddres
End If
End With
End Sub

this will help to understand what i am looking for.

"saravanan" wrote:

i want create loop for the below.

I have excel sheets contain data as below

HW INF
text39: 50

MS UP
text39: 40

the macro should move value the infront of text39: to the text39 cell and
copy the of HW INF in the same row

can any only help me.

regards

saravanan

 
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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
For/Loop skipping one value in loop only Matt Jensen Excel Programming 6 January 8th 05 12:03 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


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