Excel VBA

MVX

New Member
Joined
Oct 23, 2008
Messages
16
Help!!! Am at a loss :confused:

How do i write a macro that would look for a string (Numeric e.g. "999") in colum's 'O' - 'T'? (Columns 15 - 20)
If the string is found, i want it (the macro) too copy that entire row to a 'new' sheet (Sheet2) in the same workbook and delete the row from Sheet1?
To explain - On searching column 'O' and if string found; copy row to Sheet2: delete row from Sheet1; and then search column 'P' and so on until data sucessfully copied/deleted??
Difficulty, I have is that the same string can be repeated in different columns and unless the row once copied to 'new' sheet is deleted I would have the same 'row' copied over to Sheet2 from a different column - skewing the resulting data.

Hope this makes sense! :LOL::LOL:

Many Thanks

MVX
 
VOG
Namaste and Greetings again!
Really appreciate your help advice and assistance - The script seems to run in an endless loop without moving the 'rows' to 'Sheet2' - Just deleting!:ROFLMAO:
On stepping through 'F8' it seems to jump and ignore

Else
z = False
Is this correct? - I am at a loss how to progress

Kind Regards
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I'm sorry but I've tested this code several times now and it works for me.
 
Upvote 0
Oops! :oops:

Rich (BB code):
Sub supatest()
Dim x As Boolean
x = True
Do While x
    Call test(x)
Loop
End Sub

Sub test(z As Boolean)
Dim LR As Long, Found As Range
Set Found = Sheets("Sheet1").Columns("O:T").Find(what:=999)
If Not Found Is Nothing Then
    With Sheets("Sheet2")
        z = True
        LR = .Range("O" & Rows.Count).End(xlUp).Row
        Found.EntireRow.Copy Destination:=.Range("A" & LR + 1)
    End With
    Application.CutCopyMode = False
    Found.EntireRow.Delete
Else
    z = False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top