WantToMasterExcel
New Member
- Joined
- Feb 10, 2012
- Messages
- 20
I am trying to merge below 6 macros (from 2-7) into one macro above them named Sub Macros(1). I am getting compilation error. I am not a programmer, therefore I just play with plug n error method. I can copy Macro#1, but it is way too LONG. Thanks in advance to experts here at Mr.Excel.
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>
Sub Macro2() |
Dim wsh As Worksheet, Column As Long, lngEndRowInv As Long |
Set wsh = ActiveSheet |
i = 2 |
lngEndRowInv = wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row |
While i <= lngEndRowInv |
If Cells(i, "S") Like "*CRA*" And Cells(i, "T") Like "*CRS*" Then |
Cells(i, "AC").Value = "CRS" |
End If |
i = i + 1 |
Wend |
End Sub |
Sub Macro3() |
Dim wsh As Worksheet, Column As Long, lngEndRowInv As Long |
Set wsh = ActiveSheet |
i = 2 |
lngEndRowInv = wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row |
While i <= lngEndRowInv |
If Cells(i, "S") Like "*CUI*" And Cells(i, "T") Like "*CUI-Fund*" Then |
Cells(i, "AC").Value = "CUI" |
End If |
i = i + 1 |
Wend |
End Sub |
Sub Macro4() |
Dim wsh As Worksheet, Column As Long, lngEndRowInv As Long |
Set wsh = ActiveSheet |
i = 2 |
lngEndRowInv = wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row |
While i <= lngEndRowInv |
If Cells(i, "S") Like "*CRA*" And Cells(i, "T") Like "*CRA Corp*" Then |
Cells(i, "AC").Value = "CRA" |
End If |
i = i + 1 |
Wend |
End Sub |
Sub Macro5() |
Dim wsh As Worksheet, Column As Long, lngEndRowInv As Long |
Set wsh = ActiveSheet |
i = 2 |
lngEndRowInv = wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row |
While i <= lngEndRowInv |
If Cells(i, "S") Like "*CGC*" Then |
Cells(i, "AC").Value = "CGC" |
End If |
i = i + 1 |
Wend |
End Sub |
Sub Macro6() |
Dim Hmm As String |
Hmm = ("CCP") |
If Hmm <> vbNullString Then |
For c = 1 To Range("A" & Rows.Count).End(xlUp).Row |
If Range("AC" & c).Value = vbNullString Then |
Range("AC" & c).Value = Hmm |
End If |
Next c |
End If |
End Sub |
Sub Macro7() |
Dim LR As Range, LR2 As Range |
With Sheets("Table") |
Set LR = .Cells(.Rows.Count, "A").End(xlUp) |
End With |
With Sheets("Sheet1") |
Set LR2 = .Cells(.Rows.Count, "AC").End(xlUp) |
.Range("L2:L" & LR2.Row).Formula = "=IF(ISERROR(MATCH(AC2,Table!$A$2:$A$" & LR.Row & ",0)),"""",VLOOKUP(AC2,Table!$A$2:$F$" & LR.Row & ",2,FALSE))" |
End With |
End Sub |
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>