Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Select a range

I've included some code below that selects all the used
cells in Column C, then prompts for the current month and
enters that month in the selected range. However, if a
user adds a new row, they'd key a line number in Column B
and would use the macro to fill in the months, so the
selected range would be one row short. What I really need
is to modify the current macro to select the used cells in
Column B, then reselect the same number of cells in Column
C to include the new blank cell. Any ideas? TIA

Dim rng As Range
Dim topcell As Range
Dim botcell As Range
With Worksheets("Sheet1")
Set topcell = .Range("C2")
Set botcell = .Cells(.Rows.Count, topcell.Column).End
(xlUp)
Set rng = Range(topcell, botcell)

End With
rng.Select
Selection = InputBox(Prompt:="What month?")
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select a range

Dim rng As Range
With Worksheets("Sheet1")
set rng = .Range(.Cells(2,2), _
.Cells(rows.count,2).End(xlup)).Offset(0,1)
End With
rng.Select
Selection = InputBox(Prompt:="What month?")

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote in message
...
I've included some code below that selects all the used
cells in Column C, then prompts for the current month and
enters that month in the selected range. However, if a
user adds a new row, they'd key a line number in Column B
and would use the macro to fill in the months, so the
selected range would be one row short. What I really need
is to modify the current macro to select the used cells in
Column B, then reselect the same number of cells in Column
C to include the new blank cell. Any ideas? TIA

Dim rng As Range
Dim topcell As Range
Dim botcell As Range
With Worksheets("Sheet1")
Set topcell = .Range("C2")
Set botcell = .Cells(.Rows.Count, topcell.Column).End
(xlUp)
Set rng = Range(topcell, botcell)

End With
rng.Select
Selection = InputBox(Prompt:="What month?")



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Select a range

Eva,

Use the count of column B [correct for word wrap].

Dim rng As Range
Dim topcell As Range
Dim botcell As Range
With Worksheets("Sheet1")
Set topcell = .Range("C2")
Set botcell = .Cells(.Cells(.Rows.Count, 2).End(xlUp).Row,
topcell.Column)
Set rng = Range(topcell, botcell)

End With
rng.Select
Selection = InputBox(Prompt:="What month?")

--
sb
"Eva Shanley" wrote in message
...
I've included some code below that selects all the used
cells in Column C, then prompts for the current month and
enters that month in the selected range. However, if a
user adds a new row, they'd key a line number in Column B
and would use the macro to fill in the months, so the
selected range would be one row short. What I really need
is to modify the current macro to select the used cells in
Column B, then reselect the same number of cells in Column
C to include the new blank cell. Any ideas? TIA

Dim rng As Range
Dim topcell As Range
Dim botcell As Range
With Worksheets("Sheet1")
Set topcell = .Range("C2")
Set botcell = .Cells(.Rows.Count, topcell.Column).End
(xlUp)
Set rng = Range(topcell, botcell)

End With
rng.Select
Selection = InputBox(Prompt:="What month?")



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Select a range

Thanks to both Tom and Steve for the help; works great.
-----Original Message-----
I've included some code below that selects all the used
cells in Column C, then prompts for the current month and
enters that month in the selected range. However, if a
user adds a new row, they'd key a line number in Column B
and would use the macro to fill in the months, so the
selected range would be one row short. What I really need
is to modify the current macro to select the used cells

in
Column B, then reselect the same number of cells in

Column
C to include the new blank cell. Any ideas? TIA

Dim rng As Range
Dim topcell As Range
Dim botcell As Range
With Worksheets("Sheet1")
Set topcell = .Range("C2")
Set botcell = .Cells(.Rows.Count, topcell.Column).End
(xlUp)
Set rng = Range(topcell, botcell)

End With
rng.Select
Selection = InputBox(Prompt:="What month?")
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Select a range

Eva,

I liked Tom's solution better than my own!

But that what makes Tom, Tom...

--
sb
"Eva Shanley" wrote in message
...
Thanks to both Tom and Steve for the help; works great.
-----Original Message-----
I've included some code below that selects all the used
cells in Column C, then prompts for the current month and
enters that month in the selected range. However, if a
user adds a new row, they'd key a line number in Column B
and would use the macro to fill in the months, so the
selected range would be one row short. What I really need
is to modify the current macro to select the used cells

in
Column B, then reselect the same number of cells in

Column
C to include the new blank cell. Any ideas? TIA

Dim rng As Range
Dim topcell As Range
Dim botcell As Range
With Worksheets("Sheet1")
Set topcell = .Range("C2")
Set botcell = .Cells(.Rows.Count, topcell.Column).End
(xlUp)
Set rng = Range(topcell, botcell)

End With
rng.Select
Selection = InputBox(Prompt:="What month?")
.





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
Select used range [email protected] Excel Worksheet Functions 2 February 19th 09 03:46 AM
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
Select a range [email protected] Excel Discussion (Misc queries) 1 March 22nd 07 10:16 AM
Select Using Range vijaya Excel Discussion (Misc queries) 1 November 2nd 05 07:33 PM


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