Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to find end of rows and print message

I have this recorded macro:
Sub Macro2()
Selection.SpecialCells(xlCellTypeLastCell).Select
Range("I41").Select
Selection.End(xlToLeft).Select
ActiveCell.FormulaR1C1 = "this is a test"
Range("B41").Select
End Sub
How can I get it to go to the bottom of the data regardless of the number of
rows?
Ain't I a dummy??
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 419
Default Macro to find end of rows and print message

DumbCluck,

First, no you are not a dummy, you just don't know. Hopefully we can teach
you.

Second, what do you mean by "How can I get it to go to the bottom of the
data regardless of the number of rows?"? After it is done running, do you
want the active/selected cell to be in the last row of the data? Do you
want some message or number to be entered in one of the cells in the last
row?

Also, the last row of your data and the last row of what XL thinks is the
"Used Range" might be 2 different rows.

Your code doesn't do anything.......it just moves around to different cells
and puts "this is a test" into a cell before column I in row 41.

What would you like it to do?

If you want the active/selected cell to be in the last row of what XL thinks
is the used range, then move the line
"Selection.SpecialCells(xlCellTypeLastCell).Select " to the end (you could
have it replace "Range("B41").Select".

Now if you want the active/selected cell to be in the last row of your data,
and the last row of your data and the last row of the used range are
different, then that is slightly more complicated. I'll need to get some
more info from you. Do you want it to be any cell in the last row or a
specific cell in the last row? Also, we will need to use a column that has
contents in every row of your data in order to find the last row of your
data.

HTH,

Conan





"DumbCluck" wrote in message
...
I have this recorded macro:
Sub Macro2()
Selection.SpecialCells(xlCellTypeLastCell).Select
Range("I41").Select
Selection.End(xlToLeft).Select
ActiveCell.FormulaR1C1 = "this is a test"
Range("B41").Select
End Sub
How can I get it to go to the bottom of the data regardless of the number
of
rows?
Ain't I a dummy??



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to find end of rows and print message

Thanks Conan,
The spreadsheets are variable in the number of rows, some may have 100 rows,
some only 2.
I have 4 lines of text to enter at the end of the spreadsheet. (also would
like a
space between the data and the text.
Your suggestion works find, but now I need to drop down a line and have
another
line of text entered.
thanks for your help....I appreciate it!

"Conan Kelly" wrote:

DumbCluck,

First, no you are not a dummy, you just don't know. Hopefully we can teach
you.

Second, what do you mean by "How can I get it to go to the bottom of the
data regardless of the number of rows?"? After it is done running, do you
want the active/selected cell to be in the last row of the data? Do you
want some message or number to be entered in one of the cells in the last
row?

Also, the last row of your data and the last row of what XL thinks is the
"Used Range" might be 2 different rows.

Your code doesn't do anything.......it just moves around to different cells
and puts "this is a test" into a cell before column I in row 41.

What would you like it to do?

If you want the active/selected cell to be in the last row of what XL thinks
is the used range, then move the line
"Selection.SpecialCells(xlCellTypeLastCell).Select " to the end (you could
have it replace "Range("B41").Select".

Now if you want the active/selected cell to be in the last row of your data,
and the last row of your data and the last row of the used range are
different, then that is slightly more complicated. I'll need to get some
more info from you. Do you want it to be any cell in the last row or a
specific cell in the last row? Also, we will need to use a column that has
contents in every row of your data in order to find the last row of your
data.

HTH,

Conan





"DumbCluck" wrote in message
...
I have this recorded macro:
Sub Macro2()
Selection.SpecialCells(xlCellTypeLastCell).Select
Range("I41").Select
Selection.End(xlToLeft).Select
ActiveCell.FormulaR1C1 = "this is a test"
Range("B41").Select
End Sub
How can I get it to go to the bottom of the data regardless of the number
of
rows?
Ain't I a dummy??




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 419
Default Macro to find end of rows and print message

DumbCluck,

I would do something like this:

Sub Macro2()
dim prngLastCell as range

set prngLastCell = Selection.SpecialCells(xlCellTypeLastCell)
Range("I41").Select
Selection.End(xlToLeft).Select
ActiveCell.FormulaR1C1 = "this is a test"
cells(prngLastCell.row + 1, prngLastCell.column).select
ActiveCell = "Enter your text here"
End Sub

This will put "Enter your text here" in the cell directly below the cell
that XL thinks is the last cell (could be diffent from the last cell of your
data).

If you want a blank line between the last cell and the text, change
"cells(prngLastCell.row + 1, prngLastCell.column).select" to
"cells(prngLastCell.row + 2, prngLastCell.column).select"

HTH,

Conan




"DumbCluck" wrote in message
...
Thanks Conan,
The spreadsheets are variable in the number of rows, some may have 100
rows,
some only 2.
I have 4 lines of text to enter at the end of the spreadsheet. (also would
like a
space between the data and the text.
Your suggestion works find, but now I need to drop down a line and have
another
line of text entered.
thanks for your help....I appreciate it!

"Conan Kelly" wrote:

DumbCluck,

First, no you are not a dummy, you just don't know. Hopefully we can
teach
you.

Second, what do you mean by "How can I get it to go to the bottom of the
data regardless of the number of rows?"? After it is done running, do
you
want the active/selected cell to be in the last row of the data? Do you
want some message or number to be entered in one of the cells in the last
row?

Also, the last row of your data and the last row of what XL thinks is the
"Used Range" might be 2 different rows.

Your code doesn't do anything.......it just moves around to different
cells
and puts "this is a test" into a cell before column I in row 41.

What would you like it to do?

If you want the active/selected cell to be in the last row of what XL
thinks
is the used range, then move the line
"Selection.SpecialCells(xlCellTypeLastCell).Select " to the end (you could
have it replace "Range("B41").Select".

Now if you want the active/selected cell to be in the last row of your
data,
and the last row of your data and the last row of the used range are
different, then that is slightly more complicated. I'll need to get some
more info from you. Do you want it to be any cell in the last row or a
specific cell in the last row? Also, we will need to use a column that
has
contents in every row of your data in order to find the last row of your
data.

HTH,

Conan





"DumbCluck" wrote in message
...
I have this recorded macro:
Sub Macro2()
Selection.SpecialCells(xlCellTypeLastCell).Select
Range("I41").Select
Selection.End(xlToLeft).Select
ActiveCell.FormulaR1C1 = "this is a test"
Range("B41").Select
End Sub
How can I get it to go to the bottom of the data regardless of the
number
of
rows?
Ain't I a dummy??






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
Macro to find and paste rows kayabob Excel Discussion (Misc queries) 4 February 21st 07 01:50 AM
Macro to find and delete rows! Heather O'Malley Excel Discussion (Misc queries) 2 April 12th 06 01:53 PM
Macro to: Find a Reference, and then Paste into the 10 Rows Below Blobbies Excel Discussion (Misc queries) 9 March 14th 06 11:17 AM
Macro - message box if find nothing Frantic Excel-er Excel Discussion (Misc queries) 8 July 1st 05 08:45 PM
macro to not print blank value rows in invoice Dave Excel Worksheet Functions 1 November 3rd 04 07:21 PM


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