Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I autofill dates having a blank cell between each day? Dee New Users to Excel 1 July 3rd 08 04:59 AM
I can't autofill cells in a column if blank cells in between SJ Excel Worksheet Functions 1 May 4th 08 01:27 AM
Identify Last Cell and autofill last column manfareed Excel Programming 4 September 27th 07 03:02 AM
Autofill until blank cell is reached uberathlete[_7_] Excel Programming 3 November 5th 05 01:48 AM
Autofill until blank cell is reached uberathlete Excel Discussion (Misc queries) 7 November 4th 05 05:43 PM


All times are GMT +1. The time now is 11:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"