Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Expand Range

Hello,

I Am Making a Ledger Program,

I have the Ledger Set up Right now with the first row selected and set up as a nemed range name Ledger.

What i want is that when the user clicks a button,
it will create a new row and add it to the sheet as well as the range directly below the first ledger. It will be an alternating color, grey /blue ect

How Can i Do this?

I have tried a hundered different things but i always get this error.

object variable or with block variable not set
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Expand Range

WStoreyII,

Something like this will do the trick. As you said, the initial range
definition for Ledger is "Sheet1!$1:$1":

Sub CreateNewLedgerRow()
ActiveWorkbook.Names.Add "Ledger", "=Sheet1!" &
Range("Ledger").Offset(1).Address
With Range("Ledger")
If .Offset(-1).Interior.ColorIndex = 36 Then
.Interior.ColorIndex = 35
Else
.Interior.ColorIndex = 36
End If
End With
End Sub

The use of a single-row range makes this easy. If you want to set the
entire range as "Ledger", expand it to include the rows above it, before you
start processing.

Hope this helps,

Stan Scott
New York City

"WStoreyII" wrote in message
...
Hello,

I Am Making a Ledger Program,

I have the Ledger Set up Right now with the first row selected and set up

as a nemed range name Ledger.

What i want is that when the user clicks a button,
it will create a new row and add it to the sheet as well as the range

directly below the first ledger. It will be an alternating color, grey /blue
ect

How Can i Do this?

I have tried a hundered different things but i always get this error.

object variable or with block variable not set



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Expand Range

If your range is held within a variable, it will not be saved.

But, I managed to get around this. Put your variable in an empty cell
of the spreadsheet, and then make your sub look at this cell at the
begining and reassign the value of the cell back to the variable.

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
So frustrated. All I need to do is expand a simple range :( Arthur Pappas[_2_] Excel Discussion (Misc queries) 7 December 27th 07 07:50 AM
Expand a Named Range in 2007 Nanette New Users to Excel 2 April 26th 07 10:08 PM
Range that expand Juran Excel Discussion (Misc queries) 1 August 8th 06 01:52 AM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
Data Range Will Not Expand Dmorri254 Excel Worksheet Functions 4 April 11th 05 09:06 PM


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