LonnieP
Structural
- Oct 20, 2009
- 80
?I’m having a problem duplicating one of my old Lotus macros using Excel and VBA. It records OK when I do it manually but it’s not very versatile in that form.
The intent is to type a “filename” (without extension) into the currently active cell. Then manually move the cursor (Marque) back to the “filename”(if required), then trigger the macro using CTRL L. The macro will copy “Range1", from the named file on disk, to the currently active cell, run two additional macros (A & B) from the same file on disk, close the file on disk, then restore the screen to it’s original status. Two other cells already have range names, “Driveletter” = “C:” or any other valid logical drive, and “Directory” = “\XLshts\pool\”.
The following needs to be done by macro CTRL L:
Name the active cell “Temp1" - - (range name to be deleted at end of macro)
Open file “Driveletter”+”Directory”+contents of "Temp1"+”.XLS” - - (will always be an .XLS (single sheet) file )
Copy range “Range1" to the clipboard - - (or to cell named “Temp1" if possible to do that in one step, in which case delete the “Paste” line below)
Minimize file named in cell “Temp1"
Paste contents of clipboard to cell named “Temp1" - - (must retain formulas and external links)
Call subroutine “A” from file named in cell “Temp1" - - (Subroutine may only have a Return)
Call subroutine “B” from file named in cell “Temp1" - - (Subroutine may only have a Return)
Close file named in cell “Temp1"
Delete range name “Temp1" from current sheet
Make any screen adjustments required to regain original appearance.
Cursor (Marque) should end up where it started, over the “filename”.
End of macro
I suspect a macro like this already exists out there, I just don't know how to find it. Any help is appreciated.
LonnieP
The intent is to type a “filename” (without extension) into the currently active cell. Then manually move the cursor (Marque) back to the “filename”(if required), then trigger the macro using CTRL L. The macro will copy “Range1", from the named file on disk, to the currently active cell, run two additional macros (A & B) from the same file on disk, close the file on disk, then restore the screen to it’s original status. Two other cells already have range names, “Driveletter” = “C:” or any other valid logical drive, and “Directory” = “\XLshts\pool\”.
The following needs to be done by macro CTRL L:
Name the active cell “Temp1" - - (range name to be deleted at end of macro)
Open file “Driveletter”+”Directory”+contents of "Temp1"+”.XLS” - - (will always be an .XLS (single sheet) file )
Copy range “Range1" to the clipboard - - (or to cell named “Temp1" if possible to do that in one step, in which case delete the “Paste” line below)
Minimize file named in cell “Temp1"
Paste contents of clipboard to cell named “Temp1" - - (must retain formulas and external links)
Call subroutine “A” from file named in cell “Temp1" - - (Subroutine may only have a Return)
Call subroutine “B” from file named in cell “Temp1" - - (Subroutine may only have a Return)
Close file named in cell “Temp1"
Delete range name “Temp1" from current sheet
Make any screen adjustments required to regain original appearance.
Cursor (Marque) should end up where it started, over the “filename”.
End of macro
I suspect a macro like this already exists out there, I just don't know how to find it. Any help is appreciated.
LonnieP