PDA

View Full Version : [SOLVED] What is the code for the current date?



austenr
04-21-2005, 01:30 PM
I have a print routine that I want to add the current system date. Can anyone please tell me the code? Thanks

OBP
04-21-2005, 01:39 PM
Date() or now().

Jacob Hilderbrand
04-21-2005, 01:41 PM
Or if you are printing the same worksheet and only some of the data is changing, you can put
=Today() in the date cell and it will always be updated to the current system date.

OBP
04-21-2005, 01:55 PM
Sorry, =now() is OK but gives the time as well , but date() is Not OK and will give an error message.

mdmackillop
04-21-2005, 02:04 PM
Use Format with Now() and you can present it as you wish.


Format(Now(), "dd MMMM yyyy")

Zack Barresse
04-21-2005, 02:10 PM
Just use either of these two, no parenthasis ...


Date 'Current system date


Time 'Current system time

Note that the Date method will not have a time value associated with it; in other words it will be a whole (serial) number.

austenr
04-21-2005, 02:44 PM
Hi Zack,


I have some headings I want repeated at the top of every page. What is the best way to accomplish this?


Public Sub PrintMtvGroupList()
LastRow = Range("A65536").End(xlUp).Row
Row = 3
Range("C1:G1").Font.Bold = "True"
Range("C1").Value = "Group Name"
Range("D1").Value = "Bill Rep"
Range("E1").Value = "Ext."
Range("F1").Value = "Group #"
Range("G1").Value = "Back Up"
For i = 1 To LastRow Step 6
Range("C" & Row).Value = Range("B" & i).Text
Range("D" & Row).Value = Range("B" & i + 1).Text
Range("E" & Row).Value = Range("B" & i + 2).Text
Range("F" & Row).Value = Range("B" & i + 3).Text
Range("G" & Row).Value = Range("B" & i + 4).Text
Row = Row + 1
If Row = 40 Then
Call PrintHeadings
End If
Next i
Columns("C:G").PrintPreview
Columns("C:G").ClearContents
End Sub

Zack Barresse
04-21-2005, 03:05 PM
With code? Set up a For Each ws In ActiveWorkbook.Worksheets loop.

Manually? Select the left-most sheet, press/hold Shift, select the right-most sheet, make your change in any sheet, right click any sheet tab, select Ungroup.

I prefer the manual way. You do it once, you're done. I'm lazy. ;)

austenr
04-21-2005, 06:18 PM
Just have one sheet. Would prefer code

austenr
04-21-2005, 06:45 PM
I tried an approach where I was checking a counter I defined after each row was written but it never forced the routine to work....Here is my febile attempt..


Public Sub PrintMtvGroupList()
LastRow = Range("A65536").End(xlUp).Row
Row = 3
Range("C1:G1").Font.Bold = "True"
Range("C1").Value = "Group Name"
Range("D1").Value = "Bill Rep"
Range("E1").Value = "Ext."
Range("F1").Value = "Group #"
Range("G1").Value = "Back Up"
For i = 1 To LastRow Step 6
Range("C" & Row).Value = Range("B" & i).Text
Range("D" & Row).Value = Range("B" & i + 1).Text
Range("E" & Row).Value = Range("B" & i + 2).Text
Range("F" & Row).Value = Range("B" & i + 3).Text
Range("G" & Row).Value = Range("B" & i + 4).Text
Row = Row + 1
If Row = 40 Then
Call PrintHeadings
End If
Next i
Columns("C:G").PrintPreview
'Columns("C:G").ClearContents
End Sub

Public Sub PrintHeadings()
Range("C1:G1").Font.Bold = "True"
Range("C1").Value = "Group Name"
Range("D1").Value = "Bill Rep"
Range("E1").Value = "Ext."
Range("F1").Value = "Group #"
Range("G1").Value = "Back Up"
'Row = 0
Row = 3
End Sub

:banghead:

Zack Barresse
04-21-2005, 09:54 PM
Not sure what you mean Austen. If you only have one single Sheet, but have many pages and you have a single set of headers that you want repeated at the top of every printed page, then follow these steps ...

File (menu) --> Page Setup..
Sheet (tab)
Rows to Repeat at Top --> Select entire header rows --> Ok.

Is that what you are talking about?

austenr
04-22-2005, 09:17 AM
Thanks Zack. We can mark this one solved.