leezac
asked on
Formulas not refreshing second time button is clicked.
A button is clicked to refresh data. It works the 1st time but not the second. Is there anyone that can look at this code and tell me why it would refresh one time and not the other? It seems to refresh when the sheet is first open and initiated but not the second time.
Dim iD As Integer, iK As Integer
Dim EKN As String
EKNFormula = False
Application.EnableEvents = True
iK = 1
Sheet1.Activate
If Sheet1.CommandButton3.Capt ion = "Refresh" Then
iD = Range("J6").End(xlDown).Ro w
EKN = "=RData(J6:J" & iD & ",K4,,," & iQt & "CH:Fd" & iQt & ",K5)"
Sheet1.Range("J4").Formula = EKN
iD = iRefresh
Sheet1.CommandButton3.Capt ion = "Lock Formulas"
Else
Sheet1.CommandButton3.Capt ion = "Refresh"
End If
EKNFormula = True
End Function
Public Function iRefresh() As Integer
iRefresh = 0
While iRefresh < 55
On Error Resume Next
iRefresh = iRefresh + 1
DoEvents
Wend
ActiveSheet.Calculate
DoEvents
iRefresh = 1
End Function
Dim iD As Integer, iK As Integer
Dim EKN As String
EKNFormula = False
Application.EnableEvents = True
iK = 1
Sheet1.Activate
If Sheet1.CommandButton3.Capt
iD = Range("J6").End(xlDown).Ro
EKN = "=RData(J6:J" & iD & ",K4,,," & iQt & "CH:Fd" & iQt & ",K5)"
Sheet1.Range("J4").Formula
iD = iRefresh
Sheet1.CommandButton3.Capt
Else
Sheet1.CommandButton3.Capt
End If
EKNFormula = True
End Function
Public Function iRefresh() As Integer
iRefresh = 0
While iRefresh < 55
On Error Resume Next
iRefresh = iRefresh + 1
DoEvents
Wend
ActiveSheet.Calculate
DoEvents
iRefresh = 1
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER