Good Evening -
I am very very new to coding and have a problem with which I would very much appreciate help...
I have a spreadsheet with a data set which I have to upload. the data comes in for one month. I want to copy the data from the upload worksheet to a sheet corresponding to the date... So, i need to have a macro that can select a worksheet based on a cell value. Let's say that the date I am using is 9/30/2017. Since i cannot name a worksheet a date, I have chosen to name my worksheets Sep-17, Aug-17 etc... The initial copy and paste is a necessary function because I want the column heading to be the 9/30/2017 date instead of "Current Period" which is how it comes in from the upload.
My problem is that when i try and reformat the date after moving it - the text version = Oct-17 NOT Sep-17. My code is below. Any thoughts would be so very much appreciated. Thank you so so much
sub SelectWorksheet()
Dim strWsName As String
Dim Data As Worksheet
Worksheets("Data").Range("i2").Copy
With Worksheets("Data").Range("h1")
.PasteSpecial xlPasteFormats
.PasteSpecial xlPasteValues
End With
Dim DT As Date
DT = Date
With Worksheets("Data").Range("h1")
.NumberFormat = "@"
.Value = Format(DT, "mmm-yy")
End With
strWsName = Sheet1.Range("h1")
Sheets(strWsName).Select
End Sub
I am very very new to coding and have a problem with which I would very much appreciate help...
I have a spreadsheet with a data set which I have to upload. the data comes in for one month. I want to copy the data from the upload worksheet to a sheet corresponding to the date... So, i need to have a macro that can select a worksheet based on a cell value. Let's say that the date I am using is 9/30/2017. Since i cannot name a worksheet a date, I have chosen to name my worksheets Sep-17, Aug-17 etc... The initial copy and paste is a necessary function because I want the column heading to be the 9/30/2017 date instead of "Current Period" which is how it comes in from the upload.
My problem is that when i try and reformat the date after moving it - the text version = Oct-17 NOT Sep-17. My code is below. Any thoughts would be so very much appreciated. Thank you so so much
sub SelectWorksheet()
Dim strWsName As String
Dim Data As Worksheet
Worksheets("Data").Range("i2").Copy
With Worksheets("Data").Range("h1")
.PasteSpecial xlPasteFormats
.PasteSpecial xlPasteValues
End With
Dim DT As Date
DT = Date
With Worksheets("Data").Range("h1")
.NumberFormat = "@"
.Value = Format(DT, "mmm-yy")
End With
strWsName = Sheet1.Range("h1")
Sheets(strWsName).Select
End Sub