Komplette Zelladresse in Variabel speichern
31.03.2004 17:23:37
Franz
Die komplette Adresse, mit Worksheet und Zellen info, erhalte ich scheinbar nur wenn ich die Excel function "ADDRESS" verwende. Dazu muss ich die Adresse aber erst in eine Zelle schreiben und dann kann ich sie erst in einer Variable speichern. Ich möchte aber diesen Umweg nicht gehen und die Adresse gleich direkt in einer String Variable ablegen.
Mein Code sieht momentan so aus:
Private Sub cboCheckSums_Click()
Dim wkb As Workbook
Dim ws As Worksheet
Dim varCell As Variant
Dim intRowCount As Integer
Dim strAddress As String
intRowCount = 14
With Application.ThisWorkbook
For Each ws In .Worksheets
'find all cells in sheet with "check"
With ws
For Each varCell In .UsedRange
Select Case varCell
Case "Check"
'if check is not equal to db value then make a list of all checks that
'don't match on Sheet A (1)
If varCell.Offset(1, 2).Value <> varCell.Offset(0, 2).Value Then
With Sheets("A (1)")
.Cells(intRowCount, 16) = ws.Name
.Cells(intRowCount, 18) = varCell.Address
'Den nächsten Schritt möchte ich in VBA und nicht im Worksheet machen
.Cells(intRowCount, 19) = "=ADDRESS(" & varCell.Row & "," & varCell.Column & ",1,TRUE," _
& """" & ws.Name & """" & ")"
strAddress = .Cells(intRowCount, 19).Value
'Make a link on Sheet A (1) to the Check cell that doesn't match (on another worksheet)
.Hyperlinks.Add Anchor:=Sheets("A (1)").Cells(intRowCount, 18), _
Address:="", SubAddress:=strAddress, TextToDisplay:=varCell.Address
End With
intRowCount = intRowCount + 1
End If
End Select
Next
End With
Next
End With
End Sub
Kennt jemand eine Möglichkeit, dass ich die Adresse nicht erst ins Workbook schreiben muss und alles in VBA machen kann?
Herzlichen Dank für eure Hilfe
Franz