Need help with VBA

Associate
Joined
10 Jan 2011
Posts
62
Location
London
I know nothing of VBA, plunged into the deep end today and learning as I go.

I'm trying to do something very simple in a stock sheet, when you click on the button, it subtracts several cells and adds a date stamp.
This is what I've got.
Private Sub CommandButton1_Click()

'Subraction
For i = 3 To 11
Range("B" & i).Value = Range("B" & i).Value - Range("C" & i).Value
Next i

'Date Stamp
With Range("G3:G11")
.Value = Date
.NumberFormat = "dd/mmm"

End Sub
When I try to run it, I get the error message.

Compile Error:
Unexpected End With

Can anyone help?
 
Soldato
Joined
24 Sep 2007
Posts
4,912
Is there a With Range statement in VBA??? I am just looking at it for the first time and can only see a Range statement, try:

Code:
Private Sub CommandButton1_Click()

'Subraction
For i = 3 To 11
Range("B" & i).Value = Range("B" & i).Value - Range("C" & i).Value
Next i

'Date Stamp
Range("G3:G11")
.Value = Date
.NumberFormat = "dd/mmm"

End Sub
 
Back
Top Bottom