I'm trying to insert value ex. Canada in a column to be defined by the user (prompt) and based on cell content, column also defined by the user.
Here's my try:
Dim FinalRow As Long
Dim n As Long
Dim ColumnOU As Variant
Dim ClassifResult As Variant
'Table definition
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
ColunmOU = InputBox("Type OU column number")
ClassifResult = InputBox("Type column where yu want the countries inserted")
'Section A - Canada
For n = 2 To FinalRow
If Cells(n, ColumnOU) Like "*CANADA*" Then
Cells(n, ClassifResult) = "Canada"
End If
Next n
The macro works well if I use numbers ex. Cells(n, 5) instead of the Variant
I guess I cannot use the Variant in the range or maybe the Variant must be defined as an integer first.
thanks for your help,
Martin
Here's my try:
Dim FinalRow As Long
Dim n As Long
Dim ColumnOU As Variant
Dim ClassifResult As Variant
'Table definition
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
ColunmOU = InputBox("Type OU column number")
ClassifResult = InputBox("Type column where yu want the countries inserted")
'Section A - Canada
For n = 2 To FinalRow
If Cells(n, ColumnOU) Like "*CANADA*" Then
Cells(n, ClassifResult) = "Canada"
End If
Next n
The macro works well if I use numbers ex. Cells(n, 5) instead of the Variant
I guess I cannot use the Variant in the range or maybe the Variant must be defined as an integer first.
thanks for your help,
Martin