Excel/Please Help Me with a Macro
Expert: Adelaide carvalho - 10/29/2009
Question
Hi Adelaide,
I have an Excel Sheet named "Sample Export". if we are getting the word" Data not matching" in the column H, then it should fetch the entire row from there and paste it in another sheet.
Please help me out ..Thanks in advance...
Sandy
AnswerHi Sandy
How are you?
Please see the following
Option Base 1
Sub copying()
Rem On Error Resume Next
Const LastRow = 200
Dim R As Range, enc As Boolean, LastCol As Integer
Set R = Worksheets("Sample Export").Range("H:H")
I = 1
enc = False
R.Cells(LastRow, 1) = "Data not matching"
Do While enc = False
If R.Cells(I, 1) = "Data not matching" Then
enc = True
Else
I = I + 1
End If
Loop
If I < LastRow Then
Dim Sh(2)
Sh(1) = "Sample Export": Sh(2) = "FollowOne"
Set R = Worksheets("Sample Export").Range("1:1")
LastCol = R.Columns.Count
For S = 1 To 2
Set R = Worksheets(Sh(S)).Range("A" + LTrim(Str(I)))
For J = 1 To LastCol
R.Cells(1, J) = "Data not matching"
Next J
Next S
End If
End Sub
Cheers
Adelaide
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your
Excel question answered in this area then please ask an Excel question here