Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.office.developer.vba,microsoft.public.office.developer.com.add_ins,microsoft.public.office.developer.automation,microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
In a C++ COM add-in for Excel I need to do something with all the cells on a worksheet. I saw that I can use Worksheet.UsedRange. However, this is a read-only property. Does this mean that the range itself is read-only, or the cells that are covered by this range (I hope the cells are writable)? Then, assuming I've got a Range object, how do I iterate all the cells in it an do my processing on each cell? Regards and thanks, Levente |
#2
![]()
Posted to microsoft.public.office.developer.vba,microsoft.public.office.developer.com.add_ins,microsoft.public.office.developer.automation,microsoft.public.excel.programming
|
|||
|
|||
![]()
The UsedRange property is read-only, but the cells in it may be writable,
depending on protection/locked settings. Dim Cell as range for each cell in Activesheet.usedrange debug.print cell.address next NickHK "LF" wrote in message ... Hello, In a C++ COM add-in for Excel I need to do something with all the cells on a worksheet. I saw that I can use Worksheet.UsedRange. However, this is a read-only property. Does this mean that the range itself is read-only, or the cells that are covered by this range (I hope the cells are writable)? Then, assuming I've got a Range object, how do I iterate all the cells in it an do my processing on each cell? Regards and thanks, Levente |
#3
![]()
Posted to microsoft.public.office.developer.vba,microsoft.public.office.developer.com.add_ins,microsoft.public.office.developer.automation,microsoft.public.excel.programming
|
|||
|
|||
![]()
Nick,
Thanks fro confirming that the celss may be writable. However, this VB sample is of no use for me. I need to iterate the cells using C++. I have an Excel::_Worksheet interface pointer. Can you please explain what the VB for_each gets translated into in this case? Thanks. Best regards, Levente "NickHK" wrote in message ... The UsedRange property is read-only, but the cells in it may be writable, depending on protection/locked settings. Dim Cell as range for each cell in Activesheet.usedrange debug.print cell.address next NickHK "LF" wrote in message ... Hello, In a C++ COM add-in for Excel I need to do something with all the cells on a worksheet. I saw that I can use Worksheet.UsedRange. However, this is a read-only property. Does this mean that the range itself is read-only, or the cells that are covered by this range (I hope the cells are writable)? Then, assuming I've got a Range object, how do I iterate all the cells in it an do my processing on each cell? Regards and thanks, Levente |
#4
![]()
Posted to microsoft.public.office.developer.vba,microsoft.public.office.developer.com.add_ins,microsoft.public.office.developer.automation,microsoft.public.excel.programming
|
|||
|
|||
![]()
You'd have to ask in a C++ group what that would be.
Or use Dim i As Long With ActiveSheet.UsedRange For i = 1 To .Cells.Count MsgBox .Item(i).Address Next End With NickHK "LF" wrote in message ... Nick, Thanks fro confirming that the celss may be writable. However, this VB sample is of no use for me. I need to iterate the cells using C++. I have an Excel::_Worksheet interface pointer. Can you please explain what the VB for_each gets translated into in this case? Thanks. Best regards, Levente "NickHK" wrote in message ... The UsedRange property is read-only, but the cells in it may be writable, depending on protection/locked settings. Dim Cell as range for each cell in Activesheet.usedrange debug.print cell.address next NickHK "LF" wrote in message ... Hello, In a C++ COM add-in for Excel I need to do something with all the cells on a worksheet. I saw that I can use Worksheet.UsedRange. However, this is a read-only property. Does this mean that the range itself is read-only, or the cells that are covered by this range (I hope the cells are writable)? Then, assuming I've got a Range object, how do I iterate all the cells in it an do my processing on each cell? Regards and thanks, Levente |
#5
![]()
Posted to microsoft.public.office.developer.vba,microsoft.public.office.developer.com.add_ins,microsoft.public.office.developer.automation,microsoft.public.excel.programming
|
|||
|
|||
![]()
Nick,
The Workshhet-Cells property returns a Range object. And although Range-Count returns the number of cells (I guess), I cannot simply Index using Range-GetItem() because this methods wants a rox and a column index. And I do not know from where to where are the cells included in the range. Not to mention that a range object could contain multiple areas, each one for an isle of cells. Thus the question remains: how can I reliably iterate all the cells in a Range object? Regards and thanks, Levente "NickHK" wrote in message ... You'd have to ask in a C++ group what that would be. Or use Dim i As Long With ActiveSheet.UsedRange For i = 1 To .Cells.Count MsgBox .Item(i).Address Next End With NickHK "LF" wrote in message ... Nick, Thanks fro confirming that the celss may be writable. However, this VB sample is of no use for me. I need to iterate the cells using C++. I have an Excel::_Worksheet interface pointer. Can you please explain what the VB for_each gets translated into in this case? Thanks. Best regards, Levente "NickHK" wrote in message ... The UsedRange property is read-only, but the cells in it may be writable, depending on protection/locked settings. Dim Cell as range for each cell in Activesheet.usedrange debug.print cell.address next NickHK "LF" wrote in message ... Hello, In a C++ COM add-in for Excel I need to do something with all the cells on a worksheet. I saw that I can use Worksheet.UsedRange. However, this is a read-only property. Does this mean that the range itself is read-only, or the cells that are covered by this range (I hope the cells are writable)? Then, assuming I've got a Range object, how do I iterate all the cells in it an do my processing on each cell? Regards and thanks, Levente |
#6
![]()
Posted to microsoft.public.office.developer.vba,microsoft.public.office.developer.com.add_ins,microsoft.public.office.developer.automation,microsoft.public.excel.programming
|
|||
|
|||
![]()
You can test the .Areas.Count property of the range.
But the UsedRange is always one 1 area although another may not be. How you do this in C++ is up to you : Private Sub CommandButton1_Click() Dim r As Range Dim i As Long Dim j As Long 'Create a range of multiple areas Set r = Union(Range("A1:B2"), Range("D4:F6")) With r.Areas For j = 1 To .Count With .Item(j) For i = 1 To .Cells.Count With .Item(i) .Select MsgBox .Address End With Next End With Next End With End Sub NickHK "LF" wrote in message ... Nick, The Workshhet-Cells property returns a Range object. And although Range-Count returns the number of cells (I guess), I cannot simply Index using Range-GetItem() because this methods wants a rox and a column index. And I do not know from where to where are the cells included in the range. Not to mention that a range object could contain multiple areas, each one for an isle of cells. Thus the question remains: how can I reliably iterate all the cells in a Range object? Regards and thanks, Levente "NickHK" wrote in message ... You'd have to ask in a C++ group what that would be. Or use Dim i As Long With ActiveSheet.UsedRange For i = 1 To .Cells.Count MsgBox .Item(i).Address Next End With NickHK "LF" wrote in message ... Nick, Thanks fro confirming that the celss may be writable. However, this VB sample is of no use for me. I need to iterate the cells using C++. I have an Excel::_Worksheet interface pointer. Can you please explain what the VB for_each gets translated into in this case? Thanks. Best regards, Levente "NickHK" wrote in message ... The UsedRange property is read-only, but the cells in it may be writable, depending on protection/locked settings. Dim Cell as range for each cell in Activesheet.usedrange debug.print cell.address next NickHK "LF" wrote in message ... Hello, In a C++ COM add-in for Excel I need to do something with all the cells on a worksheet. I saw that I can use Worksheet.UsedRange. However, this is a read-only property. Does this mean that the range itself is read-only, or the cells that are covered by this range (I hope the cells are writable)? Then, assuming I've got a Range object, how do I iterate all the cells in it an do my processing on each cell? Regards and thanks, Levente |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Working with the range object | Excel Discussion (Misc queries) | |||
Working with the range object | Excel Discussion (Misc queries) | |||
returning pivottable object from a range object | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming |