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

This line in my code keeps crashing it says:" Object Variable or Wit
block variable not set"

HERE IS THE LINE:


Dim MyRange as Range

MyRange
ThisWorkbook.Worksheets("Sheet1").Range("a1").Curr entRegion.Resize(MyRange.Rows.Count
1)


Thank you for your help

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Resizing a Range

if you are trying to set a variable to a range object, you have to use set
before the variable name

Set MyRange = ThisWorkbook.Work...

Paul D

"NetWave128 " wrote in message
...
This line in my code keeps crashing it says:" Object Variable or With
block variable not set"

HERE IS THE LINE:


Dim MyRange as Range

MyRange =

ThisWorkbook.Worksheets("Sheet1").Range("a1").Curr entRegion.Resize(MyRange.R
ows.Count,
1)


Thank you for your help!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Resizing a Range

In the portion of the code "MyRange.Rows.Count", MyRange doesn't refer
to anything. The code can't cause a count of the number of rows in
MyRange because it doesn't yet know what MyRange is.

Alan Beban

NetWave128 < wrote:

This line in my code keeps crashing it says:" Object Variable or With
block variable not set"

HERE IS THE LINE:


Dim MyRange as Range

MyRange =
ThisWorkbook.Worksheets("Sheet1").Range("a1").Curr entRegion.Resize(MyRange.Rows.Count,
1)


Thank you for your help!


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Resizing a Range

This line in my code keeps crashing it says:" Object Variable or With
block variable not set"

HERE IS THE LINE:


Dim MyRange as Range

MyRange =
ThisWorkbook.Worksheets("Sheet1").Range("a1").Curr entRegion.Resize(MyRange.Rows.Count,
1)


try this:

With ThisWorkbook.Worksheets("Sheet1").Range("a1")
Set MyRange = .CurrentRegion.Resize(.CurrentRegion.Rows.Count, 1)
End With

--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

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
resizing a range of cells ckane Excel Discussion (Misc queries) 4 May 3rd 07 06:08 PM
Resizing a range of cells in a column ckane Excel Discussion (Misc queries) 0 May 3rd 07 02:38 PM
Resizing cells in a selection without resizing entire sheet Danielle via OfficeKB.com Excel Discussion (Misc queries) 4 August 11th 06 10:06 PM
Resizing Ranges Chip Pearson Excel Programming 1 August 13th 03 03:56 PM
missing items in sheet's activex list/combobox after resizing range Tim Zych[_2_] Excel Programming 1 August 11th 03 10:48 PM


All times are GMT +1. The time now is 11:48 PM.

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"