Define Range with Variant

mlanthier

New Member
Joined
Dec 8, 2011
Messages
21
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,425
Office Version
365
Platform
Windows
You've got typos in the code.
If you put
Code:
Option Explicit
at the very top of each module (before any code) it will help you to spot them.
 

Forum statistics

Threads
1,078,213
Messages
5,338,891
Members
399,265
Latest member
aj17x55

Some videos you may like

This Week's Hot Topics

Top