Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autofill with changing data

Hi!

I hope some of you will help me with this problem. I guess it is quite
simple, but I keep on getting it wrong.

My task is to fill data in the blank cells of a column with the data
already in the column. The data of the first row should be filled to
the following rows until a new default data appears. Then this data
should be filled to the next rows of this column, etc.
Example: Cell A1 = 34. Cells A2-A5 are blank. Cell A6 = 65. Cells
A7-A30 are blank, and so on. I want cells A2-A5 to be filled with "34",
cells A7-A30 to be filled with "65" and so on until a specified end.

Can anyone help me?

Thanks!!

Magnus Røed

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 238
Default Autofill with changing data

Sub fill_blanks()
For r = 2 To 50 'Change 50 to suit your last row
If Cells(r, 1) = "" Then Cells(r, 1) = Cells(r - 1, 1)
Next r
End Sub


--
Ian
--
"Mags" wrote in message
oups.com...
Hi!

I hope some of you will help me with this problem. I guess it is quite
simple, but I keep on getting it wrong.

My task is to fill data in the blank cells of a column with the data
already in the column. The data of the first row should be filled to
the following rows until a new default data appears. Then this data
should be filled to the next rows of this column, etc.
Example: Cell A1 = 34. Cells A2-A5 are blank. Cell A6 = 65. Cells
A7-A30 are blank, and so on. I want cells A2-A5 to be filled with "34",
cells A7-A30 to be filled with "65" and so on until a specified end.

Can anyone help me?

Thanks!!

Magnus Røed


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Autofill with changing data

and just to add to ian's great solution, you can use the lastrow variable
instead of a specific cell

lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row

--


Gary


"Mags" wrote in message
oups.com...
Hi!

I hope some of you will help me with this problem. I guess it is quite
simple, but I keep on getting it wrong.

My task is to fill data in the blank cells of a column with the data
already in the column. The data of the first row should be filled to
the following rows until a new default data appears. Then this data
should be filled to the next rows of this column, etc.
Example: Cell A1 = 34. Cells A2-A5 are blank. Cell A6 = 65. Cells
A7-A30 are blank, and so on. I want cells A2-A5 to be filled with "34",
cells A7-A30 to be filled with "65" and so on until a specified end.

Can anyone help me?

Thanks!!

Magnus Røed


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Autofill with changing data

Here is a non-looping approach if your column doesn't contain formulas:

Sub FillBlanks()
Dim rng As Range
Dim rng1 As Range

With ActiveSheet
Set rng = Intersect(.Columns(1), .UsedRange).Cells
End With
Set rng1 = rng.SpecialCells(xlBlanks)
rng1.Formula = "=" & rng1(0, 1).Address(0, 0)
rng.Formula = rng.Value
End Sub

--
Regards,
Tom Ogilvy


"Mags" wrote in message
oups.com...
Hi!

I hope some of you will help me with this problem. I guess it is quite
simple, but I keep on getting it wrong.

My task is to fill data in the blank cells of a column with the data
already in the column. The data of the first row should be filled to
the following rows until a new default data appears. Then this data
should be filled to the next rows of this column, etc.
Example: Cell A1 = 34. Cells A2-A5 are blank. Cell A6 = 65. Cells
A7-A30 are blank, and so on. I want cells A2-A5 to be filled with "34",
cells A7-A30 to be filled with "65" and so on until a specified end.

Can anyone help me?

Thanks!!

Magnus Røed


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
AutoFill Changing Wrong Value Lisa Excel Worksheet Functions 6 March 9th 10 02:02 PM
VLOOKUP Changing reference cells in autofill barry Excel Worksheet Functions 2 September 2nd 06 07:36 PM
Prevent Autofill from changing protected cells formatting Daren Excel Programming 0 July 11th 05 09:06 PM
cell height changing when using autofill WSCI-Nathan Excel Discussion (Misc queries) 1 January 17th 05 11:26 PM
Macro that will autofill a column with data, up to the last row of data in previous c Max Velocity Excel Programming 4 November 27th 03 10:34 AM


All times are GMT +1. The time now is 12:42 PM.

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"