Hello All,
Im trying to convert the data in certain columns to number. I need to select the rows in those columns based on the rows counted in another column with a different heading, this is because there can be breaks in the data half way down the columns.
I'm obviously very new to VBA and would like to learn from any help. I have some sample code, If anybody could correct it and tell me where I'm going wrong It would be greatly appreciated.
The Code I have so Far is:
Many Thanks in advance,
Antm79
Im trying to convert the data in certain columns to number. I need to select the rows in those columns based on the rows counted in another column with a different heading, this is because there can be breaks in the data half way down the columns.
I'm obviously very new to VBA and would like to learn from any help. I have some sample code, If anybody could correct it and tell me where I'm going wrong It would be greatly appreciated.
The Code I have so Far is:
Code:
Sub ConvertTonumber()
'Convert Certain Columns to numbers
'Use the "x"column to Calculate how many rows are required to fill the columns.
Dim ColX As Range
Set ColX = Rows(1).Find(What:="ColX", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchDirection:=xlNext, _
MatchCase:=False)
'Count the Rows in the "ColX" column
Dim J As Integer
J = ColX.Rows.Count
'Declare Headings of columns Where Text needs to be converted to 0.
Dim ConvertColTonumber As Variant, I As Long
ConvertColTonumber = Array("Y", "P", "B", "Z")
For I = LBound(ConvertColTonumber) To UBound(ConvertColTonumber)
'Set the location for the column headings to change
Dim FindHeadings As Range
Set FindHeadings = Rows(1).Find(ConvertColTonumber(I))
If FindHeadings Is Nothing Then Exit Sub
For Each Element In FindHeadings
Rows(J).Select
Selection.NumberFormat = "0"
Next
Next
End Sub
Many Thanks in advance,
Antm79