View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default How to combine lines of code?

Papa,
You can use a ":" to write more than statement on a line, but this usually
does not help readability.
As Jim indicated, use of With and also object variables make coding clearer.

NickHK

"Papa Jonah" wrote in message
...
I currently have multiple situations where code resembles the following:

Range("a" & numberrows + 1).Select
Range("a" & numberrows + 1).Formula =
"=date(YEAR(begrevdate)+1,month(begrevdate),day(be grevdate))"
Selection.NumberFormat = "m/d/yyyy"

In order to reduce the size and complexity, I would like to be able to
condense some of the coding to resemble something like:

Range("a" & numberrows + 1).Formula =
"=date(YEAR(begrevdate)+1,month(begrevdate),day(be grevdate))";

NumberFormat =
"m/d/yyyy"

I thought this was possible but my attempts to play with syntax have been
unsuccessful in getting it to work.

Any help would be much appreciated.
TIA