sindrefm
03-09-2015, 12:48 AM
Hi,
I have the following code:
Module1-----------------------------------------------------------------------------
Function FindColumn(x As String) As Long
FindColumn = Worksheets("Sheet1").Rows(1).Find(what:=x, LookAt:=xlWhole).Column
End Function
Function ConvertToNumber(x As Long) As Long
For i = 2 To .Cells(.Rows.Count, x).End(xlUp).Row
.Cells(i, x).Value = CDec(.Cells(i, x).Value)
Next
End Function
Module2------------------------------------------------------------------
Sub ConvertColumn()
Dim strVariable As String
Dim i As Long, ColVariable As Long
strVariable = "Variable"
With Worksheets("Sheet1")
ColVariable = FindColumn(strVariable)
ConvertToNumber (ColVariable)
End With
End Sub
What I want:
I want to find the "Variable" column at first row and convert all the cells in the column.
I have problems with the code marked as red, see attached picture for error message.
12976
Can someone help me on this?
I have the following code:
Module1-----------------------------------------------------------------------------
Function FindColumn(x As String) As Long
FindColumn = Worksheets("Sheet1").Rows(1).Find(what:=x, LookAt:=xlWhole).Column
End Function
Function ConvertToNumber(x As Long) As Long
For i = 2 To .Cells(.Rows.Count, x).End(xlUp).Row
.Cells(i, x).Value = CDec(.Cells(i, x).Value)
Next
End Function
Module2------------------------------------------------------------------
Sub ConvertColumn()
Dim strVariable As String
Dim i As Long, ColVariable As Long
strVariable = "Variable"
With Worksheets("Sheet1")
ColVariable = FindColumn(strVariable)
ConvertToNumber (ColVariable)
End With
End Sub
What I want:
I want to find the "Variable" column at first row and convert all the cells in the column.
I have problems with the code marked as red, see attached picture for error message.
12976
Can someone help me on this?