Autofill Copy down up until next empty row- Excel VBA Macro

0 votes

I want to paste a value into a specific cell in Column A (an empty column) and have it automatically copy down to the next empty row or to the data in Column B.

I can do this by giving a range to copy down to, but since the number of rows copied can vary, I would want this to be dynamic. There are blocks of data separated by blank rows. In essence, I'd like to copy and paste a value for each block of information in column A.

Selection.AutoFill Destination:=Range(Selection, Selection.End(xlDown)), Type:=xlFillCopy
Feb 18, 2023 in Others by Kithuzzz
• 38,010 points
1,287 views

1 answer to this question.

0 votes

Row 1048576 will be returned by end(xldown) since Column A is empty. You must check Column B for the conclusion before returning to Column A.

You can take Column B from your Selection using offset, then go back to Column A.

Selection.AutoFill Destination:=Range(Selection, Selection.Offset(0, 1).End(xlDown).Offset(0, -1)), Type:=xlFillCopy
answered Feb 18, 2023 by narikkadan
• 63,720 points

Related Questions In Others

0 votes
1 answer

Deleting Empty rows in Excel using VBA

On Error Resume Next worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete On Error GoTo 0 When ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 63,720 points
1,262 views
0 votes
1 answer

Speed up Excel vba program

Not at all. I used it. You ...READ MORE

answered Oct 20, 2022 in Others by narikkadan
• 63,720 points
600 views
0 votes
1 answer

Highlight active row/column in Excel without using VBA?

Create two formula-based rules: =ROW()=CELL("row") =COLUMN( ...READ MORE

answered Oct 27, 2022 in Others by narikkadan
• 63,720 points
2,696 views
0 votes
1 answer

Creating an unique export data VBA Macro Function in Excel

Unfortunately, the tables will vary in size. ...READ MORE

answered Nov 14, 2022 in Others by narikkadan
• 63,720 points
642 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,003 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,369 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
676 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
886 views
0 votes
1 answer

How To Copy/Cut Row of Data Based on TRUE/FALSE Condition [Excel VBA]

Solution Loop through the rows on the Price ...READ MORE

answered Feb 4, 2023 in Others by narikkadan
• 63,720 points
756 views
0 votes
1 answer

Lock down Microsoft Excel macro

Protect/Lock Excel VBA Code: When we write VBA ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 63,720 points
13,124 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP