malleshg24
07-12-2019, 10:32 PM
Hi Team
I wanted to pass dynamically array values into select Case.Instead of 'Case "Dhoni", "Sachin" , Case ar
Getting error at :=> Case arBelow are my attempted Code. Thanks in advance
Option ExplicitSub test() Dim sh1 As Worksheet Dim sh2 As Worksheet Set sh1 = ThisWorkbook.Worksheets("Sheet1") Set sh2 = ThisWorkbook.Worksheets("Mapping") Dim lr As Long lr = sh1.Cells(sh1.Rows.Count, "A").End(xlUp).Row Dim ar As Variant ar = Application.WorksheetFunction.Transpose(sh2.Range("a2:a3")) Dim i As Long For i = 2 To lr Select Case sh1.Cells(i, 1).Value 'Case "Dhoni", "Sachin" Case ar 'Getting error here want to make this line Dynamic sh1.Cells(i, 1).Font.Bold = True End Select Next i
End Sub
Regards,
mg
I wanted to pass dynamically array values into select Case.Instead of 'Case "Dhoni", "Sachin" , Case ar
Getting error at :=> Case arBelow are my attempted Code. Thanks in advance
Option ExplicitSub test() Dim sh1 As Worksheet Dim sh2 As Worksheet Set sh1 = ThisWorkbook.Worksheets("Sheet1") Set sh2 = ThisWorkbook.Worksheets("Mapping") Dim lr As Long lr = sh1.Cells(sh1.Rows.Count, "A").End(xlUp).Row Dim ar As Variant ar = Application.WorksheetFunction.Transpose(sh2.Range("a2:a3")) Dim i As Long For i = 2 To lr Select Case sh1.Cells(i, 1).Value 'Case "Dhoni", "Sachin" Case ar 'Getting error here want to make this line Dynamic sh1.Cells(i, 1).Font.Bold = True End Select Next i
End Sub
Regards,
mg