Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Trixie
 
Posts: n/a
Default Macros fill cells regardless of row number

Would like the macro to read:
Go to first blank cell in column, then copy the information from the row
above into the first blank row, without specifing the row number in the
macro, so that it remains flexible, thank you.
  #2   Report Post  
Posted to microsoft.public.excel.misc
broro183
 
Posts: n/a
Default Macros fill cells regardless of row number


Hi Trixie,

I'm assuming you have some knowledge of using macros from the wording
of your question.

Try the below code (adapted from Bob Phillip's post,
http://www.excelforum.com/showthread.php?t=500529):

Sub CopyToFirstBlankRow()
Dim LastRow As Long
LastRow = ActiveSheet.Cells(rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("A" & LastRow).EntireRow.Copy ActiveSheet.Range("A"
_
& LastRow + 1)
End Sub

fyi, Bob didn't include "activesheet." on his post but it appears that
I need it in my setup of Excel (not sure why?).

The above copies the entire row, if you only want some info copied (eg
col's A to L) try changing the copy line to something like:
ActiveSheet.Range("A" & LastRow & ":L" & LastRow).Copy _
ActiveSheet.Range("A" & LastRow + 1)

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


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

  #3   Report Post  
Posted to microsoft.public.excel.misc
Trixie
 
Posts: n/a
Default Macros fill cells regardless of row number

Thank you so much for your reply, it works very well and is much appreciated.

"broro183" wrote:


Hi Trixie,

I'm assuming you have some knowledge of using macros from the wording
of your question.

Try the below code (adapted from Bob Phillip's post,
http://www.excelforum.com/showthread.php?t=500529):

Sub CopyToFirstBlankRow()
Dim LastRow As Long
LastRow = ActiveSheet.Cells(rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("A" & LastRow).EntireRow.Copy ActiveSheet.Range("A"
_
& LastRow + 1)
End Sub

fyi, Bob didn't include "activesheet." on his post but it appears that
I need it in my setup of Excel (not sure why?).

The above copies the entire row, if you only want some info copied (eg
col's A to L) try changing the copy line to something like:
ActiveSheet.Range("A" & LastRow & ":L" & LastRow).Copy _
ActiveSheet.Range("A" & LastRow + 1)

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


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


  #4   Report Post  
Posted to microsoft.public.excel.misc
broro183
 
Posts: n/a
Default Macros fill cells regardless of row number


Hi Trixie,
Thanks for the feedback, pleased I could help.

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


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

  #5   Report Post  
Posted to microsoft.public.excel.misc
Trixie
 
Posts: n/a
Default Macros fill cells regardless of row number

No problem thank you for answering. I am a beginner at this but am lucky
enough to know exactly what I require. I am looking for other basic codes
too e.g. highlight the row the cursor is in (and spell check, or find
specific words)... Would you happen to know where I can find the basics? I
struggle with the command - in the active cell / row. Also, the macros made
the spreadsheet rather large is there any way I can recude the size? Thanks
heaps.

"broro183" wrote:


Hi Trixie,
Thanks for the feedback, pleased I could help.

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


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




  #6   Report Post  
Posted to microsoft.public.excel.misc
kevinz
 
Posts: n/a
Default Macros fill cells regardless of row number


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..


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

  #7   Report Post  
Posted to microsoft.public.excel.misc
broro183
 
Posts: n/a
Default Macros fill cells regardless of row number


Hi
" I am a beginner..." Me too, but I love the challenge!

To highlight the row the cursor is in, have a look at:
http://excelforum.com/showthread.php?t=520284

For spellcheck/find, I'd suggest starting by recording a macro of your
actions so that you have some code to modify/adapt.

" I struggle with the command - in the active cell / row. "
With regards to what?

The macro below shouldn't have made much of a difference to file size.
How large is "rather large"?
Try going to the last row, selecting all the rows underneath it & then
using the menus edit-delete (not the delete key as this just clears the
cell contents) and repeating this with the empty columns at the right of
your sheet.Also, the link below seems to have quite a few suggestions re
file size:
http://www.ozgrid.com/forum/showthread.php?p=88327

Some other sources of info for optimising macros/worksheets:
http://www.mvps.org/dmcritchie/excel/getstarted.htm (good for
beginners)
http://www.cpearson.com/excel/optimize.htm
http://www.ozgrid.com/VBA/SpeedingUpVBACode.htm
www.decisionmodels.com

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

Trixie Wrote:
No problem thank you for answering. I am a beginner at this but am
lucky
enough to know exactly what I require. I am looking for other basic
codes
too e.g. highlight the row the cursor is in (and spell check, or find
specific words)... Would you happen to know where I can find the
basics? I
struggle with the command - in the active cell / row. Also, the macros
made
the spreadsheet rather large is there any way I can recude the size?
Thanks
heaps.



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

  #8   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

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
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 04:32 PM.

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

About Us

"It's about Microsoft Excel"