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: Davi Costa   on Feb 09

No, I am trying to recalculate the range. Here are the codes.

Dim FirstAIDate As Variant
Dim SecondAIDate As Variant
Dim ThirdAIDate As Variant
Dim CmyLastRow, CmyProbRange, CmyLastCell, CmyLastARow As Variant
Dim DeleteRange As Variant
Dim CmyRange As Variant
Dim CowID As Integer
Dim CowListStart, CmyLastProbRow, CowListProbStart As range
Dim i, j, k As Integer
Dim CowStart As range
Dim message As Variant
Dim mylastRow, mylastColumn, mylastCell, myRange As range


Private Sub UserForm_initialize()


Worksheets("EnterCowData").Activate

CmyLastRow = LastCell(Worksheets("EnterCowData")).Address
CmyRange = "A3:" & CmyLastRow

'sort the range  by CowID
range(CmyRange).Select
Selection.Sort Key1:=range("A3"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal


Worksheets("EnterCowData").range(CmyRange).Name = "Options"
cboCowList.RowSource = "Options"
cboCowList.BoundColumn = 1
cboCowList.ColumnCount = 1

Application.ScreenUpdating = True

End Sub

Private Sub cboCowList_Click()

Worksheets("EnterCowData").Activate
'CmyLastARow =
Worksheets("EnterCowData").range("A65536").End(xlUp).Select
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
CmyLastARow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
MsgBox CmyLastARow
End If


CmyRange = "A3: A" & CmyLastARow
Set CowListStart = Worksheets("EnterCowData").range("A3")
CowID = cboCowList.Value
i = 0
Do Until i = CmyLastARow + 1
If CowListStart.Offset(i, 0).Value = CowID Then

k = i
End If
i = i + 1

Loop


End Sub
Private Sub cmdProblemDelete_Click()

CowID = cboCowList.Value
DeleteRange = "A" & CowListStart.Offset(k, 0).Row
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
'reset the range

Nothing execute here

End If

End Sub

'function to call values
Private Sub LoadRow()
Worksheets("EnterCowData").Cells(k, 0).Value =
Worksheets("EnterCowData").Cells((k + 1), 0).Value

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: