Fill down to last row of another column, do same thing next month but from previous last row +1 to new last row

mpaulic9

New Member
Joined
Jul 10, 2013
Messages
2
Hi All,

Hope you can help out, searching has not yielded me any results(could be lack of vba knowledge blinding me).

Each month I receive a report which has X amount of rows in it, one month more or less then the other. I then paste all these reports into one spreadsheet, month by month and build pivot tables of it to evaluate the costs compared to the other months.

The data does not have dates or anything to work with, so I manually would enter the month (e.g. JUL) and drag it down, but I'm looking for a quicker way.

So I aim to click a button and an input box shows up and then I can punch in the month (e.g. JUL) and it then will fill the empty rows in the column(M) with JUL up until the last row of data in Column A. Next month I will paste the new data into Columns (A - J) below the previous data, and I would like to click the button, type in AUG, and it then will find the new last row in column M and fill it down to the new last row in column (A).

So far I have the following code (which is obviously not complete)

Code:
Sub testinput()

Dim LastRow As Object

Set LastRow = ActiveSheet.Range("M65536").End(xlUp).Offset(1, 0)

LastMonth = InputBox("What month is this data from?. Please Use format MMM")


LastRow.Value = LastMonth
End Sub


My Logic is now telling me to Fill down LastMonth into those blank columns, but using a line such as this(below) works, however come next month I don't want it to start from "M2", I want it to start from the new last row in M and end at the new last row of A

Code:
Copydown = Range("A" & Rows.Count).End(xlUp).Row

Range(LastRow).AutoFill Destination:=Range("M2:M" & Copydown), Type:=xlFillDefault

I have tried many things, but no luck.

Any guidance would be greatly appreciated.

Note:
(excel 2003 on Win XP)



Matt
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try this:

Code:
Sub FillCol()
Dim LastRowA As Long, LastRowM As Long
Dim LastMonth As String


LastRowA = Range("A65536").End(xlUp).Row
LastRowM = Range("M65536").End(xlUp).Row


LastMonth = InputBox("What month is this data from?. Please Use format MMM")


Range(Cells(LastRowM + 1, 13), Cells(LastRowA, 13)).Value = LastMonth


End Sub
 
Last edited:
Upvote 0
Perfect, it worked.
many thanks comfy, I can now apply this to so many other things I do.

Regards
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,980
Members
448,934
Latest member
audette89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top