help autofill function to last row between 2 columns in a dynamic table

kmillanr

New Member
Joined
Jul 30, 2015
Messages
24
hello,

I have a dynamic table and i'm trying to autofill the last row between columns "H" and "P" in a table with the data of the row that is just above the last one. for example: if the table has 10 rows and the last one is empty from "H" to "P" then autofill to the last row from "h" to "p" with the functions/data/whatever that are in row 9 from columns "H" to "P". this is my code:

Sub test()

Dim isheet As Worksheet
Set isheet = ThisWorkbook.Sheets("INVENTARIO")
lrwdh = isheet.Range("h4").End(xlDown).Select
lrwdh = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select
Set lrH = Cells(Rows.Count, "H").End(xlUp).EntireRow
lrH.Select
lrH = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select
Selection.AutoFill Destination:=Range(lrHwd, lrH) HERE IS MY ERROR.... I THINK...

End Sub

thank you very much.

kevin
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
hello,

I have a dynamic table and i'm trying to autofill the last row between columns "H" and "P" in a table with the data of the row that is just above the last one. for example: if the table has 10 rows and the last one is empty from "H" to "P" then autofill to the last row from "h" to "p" with the functions/data/whatever that are in row 9 from columns "H" to "P". this is my code:

Sub test()

Dim isheet As Worksheet
Set isheet = ThisWorkbook.Sheets("INVENTARIO")
lrwdh = isheet.Range("h4").End(xlDown).Select
lrwdh = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select
Set lrH = Cells(Rows.Count, "H").End(xlUp).EntireRow
lrH.Select
lrH = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select
Selection.AutoFill Destination:=Range(lrHwd, lrH) HERE IS MY ERROR.... I THINK...

End Sub

thank you very much.

kevin

I see a "lrwdh" defined here:

Code:
lrwdh = isheet.Range("h4").End(xlDown).Select
lrwdh = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select


But in your Autofill line, you use "lrHwd"

Code:
[B]Selection.AutoFill Destination:=Range(lrHwd, lrH) [COLOR=#ff0000]'HERE IS MY ERROR.... I THINK...[/COLOR][/B]

Have you corrected the reference in your Autofill command to be:

Code:
[B]Selection.AutoFill Destination:=Range(lrwdh, lrH)[/B]
 
Upvote 0
hello,

thanks for that bit. corrected it but still gives me an error. it says: "moethod 'range' of object '_global' failed.....
i'm trying this code now:
Sub test()

Dim isheet As Worksheet
Set isheet = ThisWorkbook.Sheets("INVENTARIO")
Set lrh = Cells(Rows.Count, "H").End(xlUp).EntireRow
lrh.Select
lrh = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select
lrh = lrh

lrwdh = isheet.Range("h4").End(xlDown).Select
lrwdh = ActiveSheet.Range(Cells(ActiveCell.Row, 8), Cells(ActiveCell.Row, 17)).Select

Selection.AutoFill Destination:=Range(lrh)

End Sub

for some reason it's not reading "lrh" for my autofill destination.
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,082
Members
449,205
Latest member
Healthydogs

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