Populate to Last row - Simplify copy

Ananthak275

Board Regular
Joined
Aug 22, 2020
Messages
128
Office Version
  1. 2013
Platform
  1. Windows
  2. MacOS
Hey everyone,
My code goes into Column A, starts at row 2 and populates the values based on the last row in Column L.
1. I'm trying to make so instead of column B, it looks for the last row in the sheet, rather than a specific column.
2. Also is there a way to simplify it?

Populate_Column = "A"
DataStartRow = 2
LastRowColumn = “B"

Range(Populate_Column & DataStartRow).Select
Selection.NumberFormat = "[$-F800]dddd, mmmm dd, yyyy"
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.NumberFormat = "yyyy/mm"
Selection.AutoFill Destination:=Range(Populate_Column & DataStartRow & ":" & Populate_Column & Range(LastRowColumn & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
 
Thanks for the feed back and glade that it worked perfect for you

try this, and
VBA Code:
.NumberFormat = tdate
This is what i have and its giving me an error. it says unable to set the numberformat property of the range class
Public tdate as date

tdate = format(Date,"yy-dd"mm")

With Worksheets("sheet1") ' You can change the sheet name
With .Range("A2:A" & .Range("B" & .Rows.Count).End(xlUp).Row)
.NumberFormat = tdate
'.Value = .Value
End With
End With
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You originally said

But the code from vmjan02 is still using column B to find the last row. Yet you say it works perfectly. :unsure:
You're right. My apologies, I used your code and it worked as well thank you!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Glad we could help & thanks for the feedback.
Can you can solve this problem, im not sure how to fix it? it says unable to set the numberformat property of the range class

Public tdate as date

tdate = format(Date,"yy-dd"mm")

With Worksheets("sheet1") ' You can change the sheet name
With .Range("A2:A" & .Range("B" & .Rows.Count).End(xlUp).Row)
.NumberFormat = tdate
'.Value = .Value
End With
End With
 
Upvote 0
How about
VBA Code:
Sub Ananthak()
   Dim UsdRws As Long
   Dim tdate As String
   tdate = Format(Date, "yy-dd-mm")
   
   UsdRws = Cells.Find("*", , , , xlByRows, xlPrevious, , False).Row
   Range("A2:A" & UsdRws).Value = tdate
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub Ananthak()
   Dim UsdRws As Long
   Dim tdate As String
   tdate = Format(Date, "yy-dd-mm")
  
   UsdRws = Cells.Find("*", , , , xlByRows, xlPrevious, , False).Row
   Range("A2:A" & UsdRws).Value = tdate
End Sub
Hi sorry one more question... I have this code that finds where the data should start. The part called RelatedColumn is specifying a specific column to find to see where the data should start (+1 because there is headers). I’m trying to not use a specific column to identify where my data should start.

Is it possible to use the UsdRows instead?
RelatedColumn=“C”
StartRow = Workbooks(homefile).Sheets(homefile_sheet).Range(RelatedColumn & Rows.Count).End(xlUp).Row + 1
 
Upvote 0
Do you still need help with this?
 
Upvote 0
So do you want to insert the date from the last used row +1 in col C & copy it down to the last used row in the sheet?
 
Upvote 0
the other columns will be updated. so i want the data everytime its run to be updated to the last row.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

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