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

Dear experts,
I have a problem with the "range" Object.
I would like to find out the extent of merged cells with the following:
Do
a = a + 1
Loop Until Range(Worksheets("ASN").Cells(k + a, 2)).MergeCells = False

But I get an error: "Method "Range" of object "_Global" failed"

What does this mean? Where is the problem?
Many thanks in advance for your help.
Kind regards,
Valeria
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Range problem

Are you looking to find out how many rows and columns there are in your
merged area or, perhaps, what range of cells it is composed of? If so, you
don't need a loop to do that. Consider this (where the Range points to any
cell within the merged area (I used k and 2 because your example seems to
indicate that cell is in your merged area)...

With Range(Worksheets("ASN").Cells(k, 2)).
NumOfRows = .MergeArea.Rows.Count
NumOfColumns = .MergeArea.Columns.Count
AddressRange = .MergeArea.Address
End With

Rick


"Valeria" wrote in message
...
Dear experts,
I have a problem with the "range" Object.
I would like to find out the extent of merged cells with the following:
Do
a = a + 1
Loop Until Range(Worksheets("ASN").Cells(k + a, 2)).MergeCells = False

But I get an error: "Method "Range" of object "_Global" failed"

What does this mean? Where is the problem?
Many thanks in advance for your help.
Kind regards,
Valeria


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

Hi Rick,
I have tried but it gives me an error - "syntax error"
I am using Excel 2003
Thanks
Kins regards
--
Valeria


"Rick Rothstein (MVP - VB)" wrote:

Are you looking to find out how many rows and columns there are in your
merged area or, perhaps, what range of cells it is composed of? If so, you
don't need a loop to do that. Consider this (where the Range points to any
cell within the merged area (I used k and 2 because your example seems to
indicate that cell is in your merged area)...

With Range(Worksheets("ASN").Cells(k, 2)).
NumOfRows = .MergeArea.Rows.Count
NumOfColumns = .MergeArea.Columns.Count
AddressRange = .MergeArea.Address
End With

Rick


"Valeria" wrote in message
...
Dear experts,
I have a problem with the "range" Object.
I would like to find out the extent of merged cells with the following:
Do
a = a + 1
Loop Until Range(Worksheets("ASN").Cells(k + a, 2)).MergeCells = False

But I get an error: "Method "Range" of object "_Global" failed"

What does this mean? Where is the problem?
Many thanks in advance for your help.
Kind regards,
Valeria



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Range problem

Actually, I didn't test what I posted; I just used your structure. As it
turns out, the syntax for Range in the With statement seems to be wrong. Try
using this instead...

With Worksheets("ASN").Cells(k, 2)
Debug.Print .MergeArea.Rows.Count
Debug.Print .MergeArea.Columns.Count
Debug.Print .MergeArea.Address
End With

Rick


"Valeria" wrote in message
...
Hi Rick,
I have tried but it gives me an error - "syntax error"
I am using Excel 2003
Thanks
Kins regards
--
Valeria


"Rick Rothstein (MVP - VB)" wrote:

Are you looking to find out how many rows and columns there are in your
merged area or, perhaps, what range of cells it is composed of? If so,
you
don't need a loop to do that. Consider this (where the Range points to
any
cell within the merged area (I used k and 2 because your example seems to
indicate that cell is in your merged area)...

With Range(Worksheets("ASN").Cells(k, 2)).
NumOfRows = .MergeArea.Rows.Count
NumOfColumns = .MergeArea.Columns.Count
AddressRange = .MergeArea.Address
End With

Rick


"Valeria" wrote in message
...
Dear experts,
I have a problem with the "range" Object.
I would like to find out the extent of merged cells with the following:
Do
a = a + 1
Loop Until Range(Worksheets("ASN").Cells(k + a, 2)).MergeCells = False

But I get an error: "Method "Range" of object "_Global" failed"

What does this mean? Where is the problem?
Many thanks in advance for your help.
Kind regards,
Valeria




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default Range problem

It works!!!
Thanks a lot.
Kind regards
--
Valeria


"Rick Rothstein (MVP - VB)" wrote:

Actually, I didn't test what I posted; I just used your structure. As it
turns out, the syntax for Range in the With statement seems to be wrong. Try
using this instead...

With Worksheets("ASN").Cells(k, 2)
Debug.Print .MergeArea.Rows.Count
Debug.Print .MergeArea.Columns.Count
Debug.Print .MergeArea.Address
End With

Rick


"Valeria" wrote in message
...
Hi Rick,
I have tried but it gives me an error - "syntax error"
I am using Excel 2003
Thanks
Kins regards
--
Valeria


"Rick Rothstein (MVP - VB)" wrote:

Are you looking to find out how many rows and columns there are in your
merged area or, perhaps, what range of cells it is composed of? If so,
you
don't need a loop to do that. Consider this (where the Range points to
any
cell within the merged area (I used k and 2 because your example seems to
indicate that cell is in your merged area)...

With Range(Worksheets("ASN").Cells(k, 2)).
NumOfRows = .MergeArea.Rows.Count
NumOfColumns = .MergeArea.Columns.Count
AddressRange = .MergeArea.Address
End With

Rick


"Valeria" wrote in message
...
Dear experts,
I have a problem with the "range" Object.
I would like to find out the extent of merged cells with the following:
Do
a = a + 1
Loop Until Range(Worksheets("ASN").Cells(k + a, 2)).MergeCells = False

But I get an error: "Method "Range" of object "_Global" failed"

What does this mean? Where is the problem?
Many thanks in advance for your help.
Kind regards,
Valeria






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
Range name problem for DA Dean[_8_] Excel Programming 2 January 22nd 07 06:35 PM
Range problem David Goodall[_2_] Excel Programming 1 October 8th 05 10:45 AM
Range problem David Gerstman Excel Programming 2 May 24th 05 07:11 PM
Used Range Problem Charles Williams Excel Programming 0 August 4th 03 08:30 AM
Used Range Problem Donald Lloyd Excel Programming 6 August 3rd 03 10:18 PM


All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"