• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

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.
0
Aiysha
Asked:
Aiysha
  • 2
2 Solutions
 
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
 
Dave BrettCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now