Is there a useful tutorial on creating loops for excel projects?
Here is the code. Basically I want it to go thru each neighboring columns D & E until there is a blank and stop the code
Code: Select all
; Merge the contents of cells D2:E2
WorkBookPath := A_Desktop "\Book1.xlsx" ; store the path to the workbook
objExcel := ComObjCreate("Excel.Application") ; create a handle to a new excel application
objWorkBook := objExcel.Workbooks.Open(WorkBookPath) ; opens the existing excel table
objExcel.Visible := true ; make excel visible
objRange := objExcel.Worksheets(1).Range("D2:E2") ; store a range object
for key, val in objRange
MergedVar .= key.Value
MsgBox, % "Merged contents of D2:E2 = " MergedVar
objRange.Value := "" ; clear the contents of the range so no warning is shown when merging
objRange.Merge() ; merge the range
MsgBox, Cells Merged
objExcel.Worksheets(1).Range("F2").Value := MergedVar
;objWorkBook.Save
;objExcel.Quit()
;objExcel := ""
;ExitApp