Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Saving Worksheet/Workbook via CommandButton | Excel Programming | |||
How do I create a new commandbutton in a new workbook? | Excel Programming | |||
Commandbutton to Workbook Open | Excel Programming | |||
Delete a Commandbutton from another Workbook | Excel Programming | |||
Close WorkBook with CommandButton | Excel Programming |