Thread: VBA - Can I?
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VBA - Can I?

ps. I typed F7 instead of F9 in the code. Watch out for that typo.

Dave Peterson wrote:

You can, but wouldn't it be safer to use a formula in (say) an adjacent cell:

=F9*2

But if you want to try a macro...

Rightclick on the worksheet tab that should have this behavior. Select View
code. Paste this into the newly opened code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

With Me.Range("F7")
If Intersect(Target, .Cells) Is Nothing Then
Exit Sub
End If

If IsNumeric(.Value) Then
Application.EnableEvents = False
.Value = .Value * 2
Application.EnableEvents = True
End If
End With
End Sub

Then back to excel to test it.

robert morris wrote:

Can I use VBA code to enter a number say 1 or 2 or 3 or 4 in Col F9 and have
it multiply by a static number, say 2 and have the result display in the same
Col F9?

Bob


--

Dave Peterson


--

Dave Peterson