![]() |
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 |
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/ |
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/ |
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) |
All times are GMT +1. The time now is 08:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com