![]() |
commandbutton on workbook assistance
Hi
I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? |
commandbutton on workbook assistance
Hi Laughing Gravy,
Try posting your problematic code. However, you can almost certainly resolve your problem by explicitly qualifying your ranges. --- Regards, Norman "laughing gravy" wrote in message ... Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? |
commandbutton on workbook assistance
Try using workbook objects to make it easier to designate ranges. For
instance: dim collectWB as Workbook, applyWB as Workbook set collectWB = ThisWorkbook '....collect data, etc set applyWB = Workbooks.Open Filename:=(your file path here) Then you can reference ranges using these workbook objects without having to switch back and forth. For example, if you wanted to put the result into A1 on a sheet named "Total", you could use: applyWB.sheets("Total").range("a1").value = result 'change this variable to work for you Hope this helps. Pflugs "laughing gravy" wrote: Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? "laughing gravy" wrote: Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? |
commandbutton on workbook assistance
aha. Your a star.
thks "Pflugs" wrote: Try using workbook objects to make it easier to designate ranges. For instance: dim collectWB as Workbook, applyWB as Workbook set collectWB = ThisWorkbook '....collect data, etc set applyWB = Workbooks.Open Filename:=(your file path here) Then you can reference ranges using these workbook objects without having to switch back and forth. For example, if you wanted to put the result into A1 on a sheet named "Total", you could use: applyWB.sheets("Total").range("a1").value = result 'change this variable to work for you Hope this helps. Pflugs "laughing gravy" wrote: Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? "laughing gravy" wrote: Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? |
commandbutton on workbook assistance
No problem!
"laughing gravy" wrote: aha. Your a star. thks "Pflugs" wrote: Try using workbook objects to make it easier to designate ranges. For instance: dim collectWB as Workbook, applyWB as Workbook set collectWB = ThisWorkbook '....collect data, etc set applyWB = Workbooks.Open Filename:=(your file path here) Then you can reference ranges using these workbook objects without having to switch back and forth. For example, if you wanted to put the result into A1 on a sheet named "Total", you could use: applyWB.sheets("Total").range("a1").value = result 'change this variable to work for you Hope this helps. Pflugs "laughing gravy" wrote: Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? "laughing gravy" wrote: Hi I've dropped a commandbutton onto a work book. The button collects data from that work book when clicked and opens a different workbook to apply the data collected on to the new workbook. Alls good until I program a range/cell I want the data dumped into when I get an error 1004 message. The program still seems to be pointing at the first workbook. Any ideas how I get it to focus on the new workbook? |
All times are GMT +1. The time now is 11:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com