The simplest solution to your question would be:
With ThisWorkbook.Worksheets("Custom Systems")
.Range("G16").Value = .Range("G16").Value * .Range("c8").Value
End With
or
With ThisWorkbook.Worksheets("Custom Systems")
Set RngData = .Range("G16")
Set RngNum = .Range("c8")
RngData.Value = RngData.Value * RngNum.Value
End With
(.Value
is the default property, so that can be omitted if you want to save some characters while typing.)
If the RngData
range is not a single cell, the above method won't work. In that situation I would iterate over each cell, e.g.
Dim oneCell As Range
With ThisWorkbook.Worksheets("Sheet1")
Set rngdata = .Range("G11:G27")
Set rngnum = .Range("C6")
For Each oneCell In rngdata
oneCell.Value = oneCell.Value * rngnum.Value
Next
End With
Alternatively, you could fall back to using the built-in Paste Special Values Multiply method, e.g.
With ThisWorkbook.Worksheets("Sheet1")
Set rngdata = .Range("G11:G27")
Set rngnum = .Range("C6")
rngnum.Copy
rngdata.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlMultiply
End With
Or you could use the Evaluate
function in that situation:
With ThisWorkbook.Worksheets("Sheet1")
Set rngdata = .Range("G11:G27")
Set rngnum = .Range("C6")
'Note: The ".Value" is required in the next line or it will not work
rngdata.Value = Evaluate(rngdata.Address & "*" & rngNum.Address)
End With
Personally, I don't like the Evaluate
method - I suspect it would be more inefficient than other methods.