I have named range $A:$A Stored_Numbers and range $B:$B Corrected_Numbers .
Stored_Numbers is a list of phone numbers and Corrected_Numbers is empty (to start with).
I want to go through the list of phone numbers, run some code on the current phone number, and set the result in the corresponding cell in Corrected_Numbers .
How do I set the value of the corresponding cell in Corrected_Numbers ?
Sub Correct_Phone_Number()
' Declare variable storedNumber
Dim storedNumber As String
' Declare variable correctedNumber
Dim correctedNumber As String
' Select cell A1, *first line of data*.
Range("Stored_Numbers")(1, 1).Select
' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)
' Set variable storedNumber
storedNumber = ActiveCell
'Run some code.....
' Set variable correctedNumber
correctedNumber = result
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
End Sub
ActiveCell.Offset(0, 1).Value = correctedNumber
did the trick!
Sub Correct_Phone_Number()
' Declare variable storedNumber
Dim storedNumber As String
' Declare variable correctedNumber
Dim correctedNumber As String
' Select cell A1, *first line of data*.
Range("Stored_Numbers")(1, 1).Select
' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)
' Set variable storedNumber
storedNumber = ActiveCell
' Set variable correctedNumber
correctedNumber = storedNumber
ActiveCell.Offset(0, 1).Value = correctedNumber
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.