Month

  • Thread starter Thread starter brwilson
  • Start date Start date
B

brwilson

Excel 2000
I have a spreadsheet that posts production to a column labeled by mont
(ie Jan03, Feb 03 etc.) In the macro I am using code similar to " Rang
("C3").select " to paste the data to the proper column. At the first o
the month I have to change the code to designate the new month
starting cell ( "C3" changes to "D3").
Is there a way to automate this to change without having to change th
macro every month
 
Hi, assume row 1 has month name like Jan 03, Feb 03...


Code:
--------------------

Sub Test()
Dim buf
Dim strMonth As String
Dim i As Long
Dim rngStart As Range

'Get name of month from CustomList
buf = Application.GetCustomListContents(3)
strMonth = buf(Month(Date)) & "*"

For i = 1 To Cells(1, 256).End(xlToLeft).Column
If Cells(1, i).Value Like strMonth Then
Set rngStart = Cells(3, i)
Exit For
End If
Next

MsgBox rngStart.Address

' Use rngStart instead of ge ("C3").select
End Sub

--------------------
 
Back
Top