Hi all,
I am new to VBA so please excuse any or silly errors.
I am trying to step thru the cells in a selected range in a column.
I want to read the value of the first cell Rng(r) and if it contains the text string "total" then copy the value of another cell, 1 up and 1 to the right of that cell, to the cell to the right of the cell Rng(r).
If the text string does not contain "total" then do nothing and evaluate the next in the range using r=r+1.
here is the code, I am strugling to get the if statement to work, and the syntax.
Sub copyDescription()
'Display a messagebox based on the response
If MsgBox("Make sure the range is selected and the cells have valid values. Do you wish to continue? ", vbYesNo) = vbYes Then
'Sub routine for copying descriptions
Dim Rng As Range
Dim maxRows, r As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
r = 1
Do While r <= maxRows
if (IsNumber(Search("total", Rng(r)),ActiveCell.offset(0,1)= ActiveCell.offset(-1,1),""))
On Error Resume Next
End If
r = r + 1
Loop
MsgBox "values entered"
Else
MsgBox "Process aborted" 'Process stopped message
End If
End Sub
Bookmarks