Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Archie Evans   on Feb 09 In MS Office Category.

  
Question Answered By: Bian Nguyen   on Feb 09

Thank you for your help. Your coding is more elaborated than mine, I will try
them, I am still a beginner.

Last night I finally solved it. Here are the working codes:

Private Sub UserForm_initialize()
Call RangeSelection
cboDeleteCow.RowSource = "Options"
cboDeleteCow.BoundColumn = 1
cboDeleteCow.ColumnCount = 1
Worksheets("EnterCowData").Activate
CmyLastRow = LastCell(Worksheets("EnterCowData")).Row
CmyRange = "A3: A" & CmyLastRow
Application.ScreenUpdating = True

End Sub


Private Sub cboDeleteCow_Click()

Set CowListStart = Worksheets("EnterCowData").range("A3")
CowID = cboDeleteCow.Value
i = 0
Do Until i = CmyLastRow + 1
If CowListStart.Offset(i, 0).Value = CowID Then
DeleteRange = "A" & CowListStart.Offset(i, 0).Row
End If
i = i + 1
Loop
End Sub

Private Sub cmdProblemDelete_Click()
message = "Are you sure you want to delete cow " & CowID & "?"
If MsgBox(message, vbQuestion + vbYesNo, _
"Confirm Delete") = vbYes Then
' Delete current row:
Worksheets("EnterCowData").Activate
range(DeleteRange).EntireRow.Delete
End If

'reset the range
Call RangeSelection
End Sub

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Deleting rows and updating dynamic range Or get search suggestion and latest updates.


Tagged: