Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
resizing a range of cells | Excel Discussion (Misc queries) | |||
Resizing a range of cells in a column | Excel Discussion (Misc queries) | |||
Resizing cells in a selection without resizing entire sheet | Excel Discussion (Misc queries) | |||
Resizing Ranges | Excel Programming | |||
missing items in sheet's activex list/combobox after resizing range | Excel Programming |