Sub macroForEddie()
Dim myCell As Range
Dim myString As String
Dim myValue As Single
Set myCell = Range("C1")
Do
myString = InputBox("", "enter something for cell " & myCell.Address(False, False))
If IsNumeric(myString) Then
'user entered a number
myValue = Val(myString)
myCell = myCell + myValue
myRow = myCell.Row
'if we are out of rows, move to the next column
If myRow > 2 ^ 16 - 1 Then
Set myCell = Cells(1, myCell.Column + 1)
Else
Set myCell = myCell.Offset(1, 0)
End If
Else
'user entered a letter
Set myCell = Nothing
'is this a valid column address?
On Error Resume Next
Set myCell = Range(myString & 1)
If Err Or myCell Is Nothing Then
Err.Clear
GoTo leave
End If
End If
Loop While myString <> ""
leave:
myChoice = MsgBox("Do you want to save?", vbYesNo, "Exiting Eddie's Program")
If myChoice = vbYes Then
ThisWorkbook.Save
End If
ThisWorkbook.Close
End Sub
Bookmarks