M
mg_sv_r
Hi I have a macro where I am trying to copy the entire row of data to a new
sheet if the last two characters of a cell meets one of two conditions.
What I have so far is...
------------------------
Sub MoveRowsToBLM10()
Dim srcRange As Range
Dim dstRange As Range
Const srcSheetName = "INTERLINE_COUPON LISTING_JA (2)"
Const dstSheetName = "sheet100"
Dim Roffset As Long
Dim dstRow As Long
Worksheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "sheet100"
Worksheets(srcSheetName).Select
Range("B1").Select
Do Until ActiveCell.Row = 65535
If ActiveCell.Offset(Roffset, 0) = "78" Then
Set srcRange = Worksheets(srcSheetName). _
Rows(Roffset + 1 & ":" & Roffset + 1)
'find available row on dest sheet
dstRow = Worksheets(dstSheetName).Range("N" _
& Rows.Count).End(xlUp).Row + 1
Set dstRange = Worksheets(dstSheetName). _
Rows(dstRow & ":" & dstRow)
dstRange.Value = srcRange.Value
End If
If ActiveCell.Offset(Roffset, 0) = "88" Then
Set srcRange = Worksheets(srcSheetName). _
Rows(Roffset + 1 & ":" & Roffset + 1)
'find available row on dest sheet
dstRow = Worksheets(dstSheetName).Range("N" _
& Rows.Count).End(xlUp).Row + 1
Set dstRange = Worksheets(dstSheetName). _
Rows(dstRow & ":" & dstRow)
dstRange.Value = srcRange.Value
End If
Roffset = Roffset + 1
Loop
Set srcRange = Nothing
Set dstRange = Nothing
End Sub
----------------------
But I need to change this somehow so instead reading
If ActiveCell.Offset(Roffset, 0) = "78"
And
If ActiveCell.Offset(Roffset, 0) = "88"
I need it to look to see if just the last two characters of the cell are
"78" or "88"
Can anyone point give me some tips on doing this please.
Regards
John
sheet if the last two characters of a cell meets one of two conditions.
What I have so far is...
------------------------
Sub MoveRowsToBLM10()
Dim srcRange As Range
Dim dstRange As Range
Const srcSheetName = "INTERLINE_COUPON LISTING_JA (2)"
Const dstSheetName = "sheet100"
Dim Roffset As Long
Dim dstRow As Long
Worksheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "sheet100"
Worksheets(srcSheetName).Select
Range("B1").Select
Do Until ActiveCell.Row = 65535
If ActiveCell.Offset(Roffset, 0) = "78" Then
Set srcRange = Worksheets(srcSheetName). _
Rows(Roffset + 1 & ":" & Roffset + 1)
'find available row on dest sheet
dstRow = Worksheets(dstSheetName).Range("N" _
& Rows.Count).End(xlUp).Row + 1
Set dstRange = Worksheets(dstSheetName). _
Rows(dstRow & ":" & dstRow)
dstRange.Value = srcRange.Value
End If
If ActiveCell.Offset(Roffset, 0) = "88" Then
Set srcRange = Worksheets(srcSheetName). _
Rows(Roffset + 1 & ":" & Roffset + 1)
'find available row on dest sheet
dstRow = Worksheets(dstSheetName).Range("N" _
& Rows.Count).End(xlUp).Row + 1
Set dstRange = Worksheets(dstSheetName). _
Rows(dstRow & ":" & dstRow)
dstRange.Value = srcRange.Value
End If
Roffset = Roffset + 1
Loop
Set srcRange = Nothing
Set dstRange = Nothing
End Sub
----------------------
But I need to change this somehow so instead reading
If ActiveCell.Offset(Roffset, 0) = "78"
And
If ActiveCell.Offset(Roffset, 0) = "88"
I need it to look to see if just the last two characters of the cell are
"78" or "88"
Can anyone point give me some tips on doing this please.
Regards
John