UVERtainment
UVERtainment

Reputation: 35

VBA How to increment a number and return it to use again?

it's kinda similar to a loop but i want to have an input after every increment.

in short, i have a textbox linked to a cell in Excel. i wrote up a script that compares the value in the textbox to the sheet to tally and put a tick in the cell.

however after that i want to move a cell down as well as checking the next value.

so far, i've been trying for, while.. loops but it just keeps looping before i had a chance to enter the next value to compare.

so is there a way i can code it to make the loop pause, and then cont after i enter the value and comparing it?

Upvotes: 0

Views: 2136

Answers (1)

Nathan_Sav
Nathan_Sav

Reputation: 8531

something like this

Option Explicit

Public lngRowNumber As Long

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TESTING lngRowNumber
    lngRowNumber = lngRowNumber + 1
End Sub

Private Sub UserForm_Initialize()
    lngRowNumber = 1
End Sub

Private Sub TESTING(ByVal lngRowNumber As Long)
    MsgBox "Updated Row : " & lngRowNumber
End Sub

Upvotes: 1

Related Questions