Code to multiply two cells?

  • Thread starter Thread starter Tdp
  • Start date Start date
Thanks for that J.
I assume if it`s in sheet4 then I write
Worksheets("Sheet4").Range("D4") = Range("E4")*Range("F4")
?
 
You can qualify all the pieces:

Sub dural()
With Worksheets("Sheet4")
..Range("D4") = .Range("E4") * .Range("F4")
End With
End Sub
 
As I wrote it, it would automatically apply to the "active sheet".

But since you may want it to go to another sheet, then the way you wrote it
would work. Might have to treat the E4 and F4 references the same way also,
i.e. specifically referencing the worksheet(s) they are on also.

Other than taking a little extra time to resolve the location, it never
hurts to use the worksheet name along with the address; and sometimes it is a
must do.
 
Thank you both. very useful
--
Tdp


JLatham said:
As I wrote it, it would automatically apply to the "active sheet".

But since you may want it to go to another sheet, then the way you wrote it
would work. Might have to treat the E4 and F4 references the same way also,
i.e. specifically referencing the worksheet(s) they are on also.

Other than taking a little extra time to resolve the location, it never
hurts to use the worksheet name along with the address; and sometimes it is a
must do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top