ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Month (https://www.excelbanter.com/excel-programming/285098-month.html)

brwilson[_4_]

Month
 
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

--
Message posted from http://www.ExcelForum.com


Colo[_16_]

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

--------------------



---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 07:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com