How to format yyyymmdd with Button and VBA ??

  • Thread starter Thread starter tmb
  • Start date Start date
T

tmb

I tried this...

Sub Button8_Click()
Sheets("Sheet1").Select
Range("C10").Select
ActiveCell.FormulaR1C1 = Now()
ActiveCell.AutoFormat = yyyymmdd ' WRONG
End Subf

But the last line is not correct. I don't know how to code it.

Can anybody help me out?

thanks
 
Sub Button8_Click()
with worksheets("sheet1").range("c10")
.value = now 'include the time, too???
' .value = date 'if you want to avoid the time.
.numberformat="yyyymmdd"
end with
End Sub

You don't need to select stuff to work with them (for the most part).
 
Dave,

Thanks for the help.

would you do the time like this...

Sub Button8_Click()
with worksheets("sheet1").range("c10")
.value = time
.numberformat="hhmmss"
end with

thanks,

tmb
 
What happened when you tried it <vbg>???

(it worked fine for me--well, when I added an "End Sub".)
 
Back
Top