Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Dates in VBA
I'm trying to do something very simple in Visual Basic, but am having
trouble. All I want to do is put a date in a certain cell, based on a date in a different cell on a different sheet. The formula I would use if it weren't visual basic is: =DATE(Year(Info!G2),Month(Info!G2),1) How can I do this using visual basic? Thanks! Brett |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Dates in VBA
dim myCell as range
set mycell = worksheets("info").range("G2") with activecell .numberformat = "mm/dd/yyyy" .value = dateserial(year(mycell.value), month(mycell.value), 1) end with wrote: I'm trying to do something very simple in Visual Basic, but am having trouble. All I want to do is put a date in a certain cell, based on a date in a different cell on a different sheet. The formula I would use if it weren't visual basic is: =DATE(Year(Info!G2),Month(Info!G2),1) How can I do this using visual basic? Thanks! Brett -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Dates in VBA
info!G2 === Worksheets("Info").Range("G2") in VBA
Range("a1") = DateSerial(Year(Worksheets("Info").Range("G2")), Month(Worksheets("Info").Range("G2")), 1) " wrote: I'm trying to do something very simple in Visual Basic, but am having trouble. All I want to do is put a date in a certain cell, based on a date in a different cell on a different sheet. The formula I would use if it weren't visual basic is: =DATE(Year(Info!G2),Month(Info!G2),1) How can I do this using visual basic? Thanks! Brett |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Dates in VBA
That did it! Thanks a lot!
Dave Peterson wrote: dim myCell as range set mycell = worksheets("info").range("G2") with activecell .numberformat = "mm/dd/yyyy" .value = dateserial(year(mycell.value), month(mycell.value), 1) end with wrote: I'm trying to do something very simple in Visual Basic, but am having trouble. All I want to do is put a date in a certain cell, based on a date in a different cell on a different sheet. The formula I would use if it weren't visual basic is: =DATE(Year(Info!G2),Month(Info!G2),1) How can I do this using visual basic? Thanks! Brett -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Dates showing are not what I type | New Users to Excel | |||
Dates and Intervals | Excel Worksheet Functions | |||
formula to add dates. | Excel Worksheet Functions | |||
need to convert list of dates to count no. of dates by week | Excel Worksheet Functions | |||
Calculating number of days between two dates that fall between two other dates | Excel Discussion (Misc queries) |