Guest_imported
New member
- Jan 1, 1970
- 0
I'm writing an Excel macro to convert the format of the spreadsheet to a style that can be read by our MileMaker program (i.e. a batch report). I've got the cell manipulating set up just fine, and the loop to continue the program until the active cell is empty. The only problem I'm having is that I need to insert "OR" and "DT" in front of them. Here is the code for it as of now:
Sub change_before_do_loop()
Do Until IsEmpty(ActiveCell)
Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Range("A1".Select
Selection.EntireRow.Insert
ActiveCell.Offset(-1, 0).Range("A1".Select
Selection.Cut
ActiveCell.Offset(1, -2).Range("A1".Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 3).Range("A1".Select
Selection.Cut
ActiveCell.Offset(1, -2).Range("A1".Select
ActiveSheet.Paste
ActiveCell.Offset(-2, -1).Range("A1".Select
ActiveCell.FormulaR1C1 = "HRMI"
ActiveCell.Offset(1, 0).Range("A1".Select
Selection.TypeText Text:="OR"
ActiveCell.Offset(1, 0).Range("A1".Select
Selection.TypeText Text:="DT"
ActiveCell.Offset(1, 2).Range("A1".Select
Loop
End Sub
The Selection.TypeText, however, does not work correctly, giving me an error message stating that the object or method does not exist. Can anyone offer some help? I just need to know how to insert letters in front of strings, basically. The problem may be that "Selection" is not reading correctly as the variable, I don't know. Thanks,
Nathan
Sub change_before_do_loop()
Do Until IsEmpty(ActiveCell)
Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Range("A1".Select
Selection.EntireRow.Insert
ActiveCell.Offset(-1, 0).Range("A1".Select
Selection.Cut
ActiveCell.Offset(1, -2).Range("A1".Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 3).Range("A1".Select
Selection.Cut
ActiveCell.Offset(1, -2).Range("A1".Select
ActiveSheet.Paste
ActiveCell.Offset(-2, -1).Range("A1".Select
ActiveCell.FormulaR1C1 = "HRMI"
ActiveCell.Offset(1, 0).Range("A1".Select
Selection.TypeText Text:="OR"
ActiveCell.Offset(1, 0).Range("A1".Select
Selection.TypeText Text:="DT"
ActiveCell.Offset(1, 2).Range("A1".Select
Loop
End Sub
The Selection.TypeText, however, does not work correctly, giving me an error message stating that the object or method does not exist. Can anyone offer some help? I just need to know how to insert letters in front of strings, basically. The problem may be that "Selection" is not reading correctly as the variable, I don't know. Thanks,
Nathan