as I am a complete newb in VBA, I have a question.
I have a column of integers, which I want to divide by 60. The column is "X". Here's my code:
For Each element In Worksheets("parsed").Range("X1:X" & MaxRows).Cells
element.Value = element.Value / 60
Next
But I always get "type mismatch". What I am doing wrong?
First, make sure that you declare
element
as a range. Second, remove the.cells
from your loop. This then effectively says in your loop statementFor each cell in the range
like so:I've made the assumption that
MaxRows
is intended as the last row in columnX
of the worksheet.