• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Entering a formula in a cell using VBA

delta

Member
i put the vba macro by Worksheet_Change(ByVal Target As Range) method

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
  Application.EnableEvents = False
  If (Target.Address = Range("A1").Address) Then Range("C10").Value = Range("A1").Value * 7
  Application.EnableEvents = True
End Sub

i want to when enter any number in cell "A1" the result will be show in cell "C10" but i did not any number in cell "A1" the result will be show in cell "C10" is 0 (zero) but i did not show o (Zero) how it possible. i do this only
Worksheet_Change(ByVal Target As Range) method only. i upload file for more clarification


▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !
 

Attachments

  • Cell Rang.xlsm
    13.1 KB · Views: 1
I think you're saying that if A1 is blank, you don't want anything to appear in C10?

try this code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngConcern As Range
    Dim rngOutput As Range
    Dim myVal As Long
  
    'What cell are you watching?
    Set rngConcern = Range("A1")
    'What cell gets output?
    Set rngOutput = Range("C10")
  
    'Check if we edited the cell of interest
    If Intersect(Target, rngConcern) Is Nothing Then Exit Sub
  
    Application.EnableEvents = False
    'Do nothing for blank cells
    If rngConcern.Value = "" Then
        rngOutput.ClearContents
    Else
        'Make our change       
        rngOutput.Value = rngConcern.Value * 7       
    End If
    Application.EnableEvents = True
End Sub
 
i upload the file in Bill sheet the "Qty" heading range "E19:E28" multiply with "Rate" heading F19:F28 and out in heading "Value" "G19"G28" but condition is that when i enter in number in cell "F19" as respectively other cell then output will be shown other wise nothing not 0 (zero)
 

Attachments

  • PSC_2017.xlsm
    79.5 KB · Views: 1
I don't see how this new workbook has anything to do with a macro. In G19, put this formula, then copy down.

=IF(B19="","",E19*F19)
 
Back
Top