MrCameronExcel
New Member
- Joined
- Apr 21, 2017
- Messages
- 43
- Office Version
- 365
- Platform
- Windows
Hi MrExcel users,
I am new to VBA, and am following along with a youtube channel to learn:
(https://www.youtube.com/watch?v=S55...Hv2ztGjIkrW7suD6oNDaOk3vbR&index=8#t=0.576114)
Although I am following his steps exactly, my VBA sheet needs bugging, and his does not. Is there something missing in my code - see below? Also, if you have any recommendations on how to self-teach Excel VBA, I would love to know how to best learn this language!
Thank you
Sub Test1()
Dim mrsheet As Worksheet
Set mrsheet = ThisWorkbook.Sheets("My Report")
'Get last row of worksheet
Lastrow = mrsheet.Cells(Rows.Count, 1).End(x1up).Row
'Clears out last report
mrsheet.Range("a2:c" & Lastrow).ClearContents
For x = 2 To 500
mrsheet.Cells(x, 1) = Date + 7
mrsheet.Cells(x, 2) = x * 15
If mrsheet.Cells(x, 2) > 100 Then
mrsheet.Cells(x, 3) = True
Else
mrsheet.Cells(x, 3) = False
End If
Next x
End Sub
I am new to VBA, and am following along with a youtube channel to learn:
(https://www.youtube.com/watch?v=S55...Hv2ztGjIkrW7suD6oNDaOk3vbR&index=8#t=0.576114)
Although I am following his steps exactly, my VBA sheet needs bugging, and his does not. Is there something missing in my code - see below? Also, if you have any recommendations on how to self-teach Excel VBA, I would love to know how to best learn this language!
Thank you
Sub Test1()
Dim mrsheet As Worksheet
Set mrsheet = ThisWorkbook.Sheets("My Report")
'Get last row of worksheet
Lastrow = mrsheet.Cells(Rows.Count, 1).End(x1up).Row
'Clears out last report
mrsheet.Range("a2:c" & Lastrow).ClearContents
For x = 2 To 500
mrsheet.Cells(x, 1) = Date + 7
mrsheet.Cells(x, 2) = x * 15
If mrsheet.Cells(x, 2) > 100 Then
mrsheet.Cells(x, 3) = True
Else
mrsheet.Cells(x, 3) = False
End If
Next x
End Sub