![]() |
VBA to autofill next blank cell in same column
Hi ,
I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Sub ABC()
set rng = cells(rows.count,1).End(xlup) rng.offset(1,0).Filldown End Sub -- Regards, Tom Ogilvy "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Sub fill_er_up()
n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Value = Cells(i - 1, 1).Value End If Next End Sub this is coded for column A, can be modified for any column. -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Hi Tom,
Thanks but this does not work in this instance. Regards, Manir "Tom Ogilvy" wrote: Sub ABC() set rng = cells(rows.count,1).End(xlup) rng.offset(1,0).Filldown End Sub -- Regards, Tom Ogilvy "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Hi,
It works but how do I ensure that it is the same format as the line above i.e. font colour etc. Thanks, Manir "Gary''s Student" wrote: Sub fill_er_up() n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Value = Cells(i - 1, 1).Value End If Next End Sub this is coded for column A, can be modified for any column. -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Sub ABC()
Dim rng As Range, ar As Range Set rng = Columns(1).SpecialCells(xlBlanks) For Each ar In rng.Areas ar(0).Copy ar Next End Sub -- Regards, Tom Ogilvy "manfareed" wrote: Hi, It works but how do I ensure that it is the same format as the line above i.e. font colour etc. Thanks, Manir "Gary''s Student" wrote: Sub fill_er_up() n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Value = Cells(i - 1, 1).Value End If Next End Sub this is coded for column A, can be modified for any column. -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Sub fill_er_up2()
n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).FillDown End If Next End Sub -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi, It works but how do I ensure that it is the same format as the line above i.e. font colour etc. Thanks, Manir "Gary''s Student" wrote: Sub fill_er_up() n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Value = Cells(i - 1, 1).Value End If Next End Sub this is coded for column A, can be modified for any column. -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Excellent ...
Thanks "Tom Ogilvy" wrote: Sub ABC() Dim rng As Range, ar As Range Set rng = Columns(1).SpecialCells(xlBlanks) For Each ar In rng.Areas ar(0).Copy ar Next End Sub -- Regards, Tom Ogilvy "manfareed" wrote: Hi, It works but how do I ensure that it is the same format as the line above i.e. font colour etc. Thanks, Manir "Gary''s Student" wrote: Sub fill_er_up() n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Value = Cells(i - 1, 1).Value End If Next End Sub this is coded for column A, can be modified for any column. -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
VBA to autofill next blank cell in same column
Many Thanks ...
"Gary''s Student" wrote: Sub fill_er_up2() n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).FillDown End If Next End Sub -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi, It works but how do I ensure that it is the same format as the line above i.e. font colour etc. Thanks, Manir "Gary''s Student" wrote: Sub fill_er_up() n = Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To n If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Value = Cells(i - 1, 1).Value End If Next End Sub this is coded for column A, can be modified for any column. -- Gary''s Student - gsnu200747 "manfareed" wrote: Hi , I have data in column A in sa "A2". If "A3" is blank then I want to copy the value from "A2". Next I would expect the macro to go to the next populated cell in column A eg. "A4" and copy "A4" to "A5" and so forth. Thanks, Manir |
All times are GMT +1. The time now is 01:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com