LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.misc
broro183
 
Posts: n/a
Default Macros fill cells regardless of row number


hi Kevinz,

How many rows are in the spreadsheet?
If there are not many rows & it only has to be done once the quickest
approach would have been to do it manually!
In terms of "teaching a man to fish", the manual approach could be
recorded into a macro & adapted from there - as below:
recorded code:
ActiveCell.Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Range("A1:A14").Select
ActiveSheet.Paste

This can be adapted as follows but b/c I can't tell if you want the
complete row copied in rows 2 to 500 or just the info in some cells eg
A2:IV500 or A2:A500 I'll show you both...

Sub *CopyingBlanksBelowPopulatedCells*()
Dim bottomOfLastCopiedSection As Long
Repeat:
bottomOfLastCopiedSection = Selection.End(xlDown).Row
If bottomOfLastCopiedSection = rows.Count Then
MsgBox "all copying except last section complete. Please copy this
section manually."
Exit Sub
Else
ActiveCell.Range("A1").Copy Range(Selection,
Selection.End(xlDown).Offset(RowOffset:=-1))
Selection.End(xlDown).Activate
End If
GoTo Repeat
End Sub

Sub *CopyingBlanksBelowPopulatedRows*()
Dim bottomOfLastCopiedSection As Long
Repeat:
bottomOfLastCopiedSection = Selection.End(xlDown).Row
If bottomOfLastCopiedSection = rows.Count Then
MsgBox "all copying except last section complete. Please copy this
section manually."
Exit Sub
Else
ActiveCell.Range("A1").EntireRow.Copy Range(Selection,
Selection.End(xlDown).Offset(RowOffset:=-1))
Selection.End(xlDown).Activate
End If
GoTo Repeat
End Sub

There will be tidy ways of doing this but I don't know them & I can't
tell from your post how to recognise the end of used area which is why
I have finished it with a message to do the last section manually.
(fyi, a solution will probably involve checking the intersection of the
used range with the active cell).

Rob Brockett
NZ
Always learning & the best way to learn is to experience...


kevinz Wrote:
This post was EXACTLY what I was looking for.. Although I am pretty new
to excel and am having some problems.

I did it to run but it is not going to the first blank cell, is it
going to the first blank cell at the bottom and copying and filling.
Is there a way to change that?

Basically what I have and need to do is..
Row1 = "Blah"
Then the next 500 rows under that column are empty.

Row 501 = "SomethingElse" Then blank rows until whatever..

I need something to fill in 2-500 with "Blah"

Then 502-whatever with "SomethingElse"

I hope that takes sense, from reading the post about this.. That is
what it is suppose to do but I can't get it to work. I just jumps to
the very bottom and starts and skips all the blank rows above it.

Any help would be so greatly appreciated, I have been messing with this
for hours and I need to get it done tonight..



--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=524172

 
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
Excell-How to add the number of cells containing text? = a sum aruba64taw Excel Worksheet Functions 2 December 21st 05 09:51 AM
Sum cells by fill colour jamiemal Excel Discussion (Misc queries) 2 August 17th 05 01:51 PM
Number format exactly the same, displays differently in some cells eider Excel Discussion (Misc queries) 1 July 29th 05 12:26 AM
Copy down - special to fill only the blank cells Mike Excel Discussion (Misc queries) 3 April 18th 05 10:08 PM
Fill cells from non-adjacent cells Abes Excel Discussion (Misc queries) 2 March 25th 05 01:15 PM


All times are GMT +1. The time now is 03:00 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"