Find the row from cell reference (VBA)

I was to delete a row from cell reference.

I have created a macro that returns the address of  a cell eg. $A$15 in a variable.
With this address I was to created a code that deletes row 15.

more examples  $B$5  delete row 5
                        $c$20 delete row 20

I was thinking of using left(variable,2) but this doesnt work..

Thank you in advance.
AiyshaAsked:
Who is Participating?
 
ShauliCommented:
Option Compare Database

Private Sub Command0_Click()
MsgBox GetRow("$c$20")
End Sub

Function GetRow(ByVal CellAddress As String) As String
Dim mySplit() As String
mySplit = Split(CellAddress, "$", -1)
GetRow = mySplit(UBound(mySplit))
End Function

S
0
 
ShauliCommented:
ps. I think its time to close those 11 open paqs, Aiysha. Some of them are more than a month old.

S
0
 
DaveCommented:
Using the range object is probably easiest, see KillRange.

Sub TestSub()
KillRange ("$A$15")
End Sub

Sub KillRange(Addr As String)
Dim myrange As Range
Set myrange = Range(Addr)
myrange.EntireRow.Delete
End Sub

Cheers

Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.