Opet resim maly problem: jak makrem prepsat cca 40 oblasti bunek stejnou hodnotou napr. "1". Dohromady je to neco pres 1200 bunek. Ma to malou vyhodu: co oblast, to jen 1 sloupec, ale ruzny pocet radku.
Momentalne to resim ulozenim jednotlivych nazvu do array a pres cyklus: zjisteni adresy oblasti a prepsani kazde bunky. A ted ten problem: pokud to pustim na listu, kde dochazi ke zmene, bezi to trosku pomaleji nez bych si predstavoval, chapu 1200 bunek neni malo, ale slape to...
Ale pokud to pustim z jineho listu (coz potrebuji), LO bez udani duvodu spadne. Muze to byt tim zanorenym cyklem?
Poradite, prosim, cim by to mohlo byt? Prip. nejake lepsi reseni jak toto resit?
EDIT: upravovane bunky nabyvaji hodnoty: 0 a 1
Sub SetZero
oStorageSheet = ThisComponent.Sheets.GetByName("Sheet3")
Dim MyArray(1 To 2) As String
MyArray(1) = "oblast01"
MyArray(2) = "oblast02"
For i = 1 To UBound(MyArray)
oCells = SplitString(GetRangeAddress(MyArray(i))(0),".",2)
oRowStart = GetRangeAddress(MyArray(i))(1)
oRows = GetRangeAddress(MyArray(i))(2)-oRowStart+1
oColumn = Mid(oCells, 2, 1)
For n = 1 To oRows
oRow = oRowStart + n
oCellTarget = oStorageSheet.GetCellRangeByName(oColumn & oRow)
If oCellTarget.Value > 0 Then
oCellTarget.Value = 0
End If
Next n
Next i
End Sub
Sub GetRangeAddress(oRange As String) As Array
Dim r As Object
Dim rAddress as New com.sun.star.table.CellRangeAddress
r = ThisComponent.NamedRanges.getByName(oRange).ReferredCells
rAddress = r.RangeAddress
GetRangeAddress = array(r.AbsoluteName, rAddress.StartRow, rAddress.EndRow)
End Sub
Function SplitString(oString, Separator, Rank)
Rank = Rank-1
Items = Split(oString, Separator)
If Rank < 0 OR Rank > UBound(Items) Then
SplitString = ""
Else
SplitString = Items(Rank)
End If
End Function