Philip1957
Board Regular
- Joined
- Sep 30, 2014
- Messages
- 185
- Office Version
- 365
- Platform
- Windows
Greetings,
This is my first attempt at using the Input Box Method.
I have this piece of code that strips away extraneous characters and leaves just the serial number:
The serial number data may not always be in column A however, so I'm trying to use the Input Box to allow the user to specify the column.
I've tried various permutations of the following with no luck:
This hangs at the Range statement before the Do Until, with an error message of Run-time error '1004': Method 'Range' of 'object_Global' failed.
I'm also unclear if the user should select the whole column, a cell in that column, or just input the letter.
Any assistance would be greatly appreciated.
Thanks,
~ Phil
This is my first attempt at using the Input Box Method.
I have this piece of code that strips away extraneous characters and leaves just the serial number:
Code:
Option Explicit
Sub Extract_Count()
Application.ScreenUpdating = False
'Change Column Headings
ActiveSheet.Range("B1").Select
ActiveCell.Value = "Assy #"
ActiveSheet.Range("C1").Select
ActiveCell.Value = "Sta #"
ActiveSheet.Range("D1").Select
ActiveCell.Value = "Date"
' Trim Away all but S/N
Range("A" & Rows.Count).End(xlUp).Select
Do Until ActiveCell.Address = "$A$1"
ActiveCell = Right(ActiveCell, Len(ActiveCell) - 55)
ActiveCell = Left(ActiveCell, Len(ActiveCell) - 4)
ActiveCell.Offset(-1, 0).Select
Loop
Application.ScreenUpdating = True
End Sub
The serial number data may not always be in column A however, so I'm trying to use the Input Box to allow the user to specify the column.
I've tried various permutations of the following with no luck:
Code:
Option Explicit
Sub Clean_Serial_Numbers()
Dim myCol As Range
Set myCol = Application.InputBox("Select the column with the serial number data.", Type:=8)
Range("myCol" & Rows.Count).End(xlUp).Select
Do Until ActiveCell.Address = "$myCol$1"
ActiveCell = Right(ActiveCell, Len(ActiveCell) - 55)
ActiveCell = Left(ActiveCell, Len(ActiveCell) - 4)
ActiveCell.Offset(-1, 0).Select
Loop
End Sub
This hangs at the Range statement before the Do Until, with an error message of Run-time error '1004': Method 'Range' of 'object_Global' failed.
I'm also unclear if the user should select the whole column, a cell in that column, or just input the letter.
Any assistance would be greatly appreciated.
Thanks,
~ Phil