Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default command button move worksheet from one workbook to another

This will prolly go unanswered but..I have worksheets emp1 thru emp24. I
would like to place a command button on each sheet that when clicked will
allow me to move the sheet to another excel file that had tne same name but
is in a different folder. In addition I'd like the worksheet to take the
place of one of the worksheets in the new file as long as the worksheet does
not have a value in cell B4. So if file 1 emp5 is moved to file 2 it looks
for the first sheet with an empty B4 in file 2 and replaces it with the
worksheet from file1. So in theory file1 emp5 could become file2 emp8.I'd
also like file1 emp5 to retain its name but be clear of information in
unlocked cells (if it matters the worksheets are protected). Each employee
has his own worksheet but may switch teams at any time. Each team has it's
own file. I know I'm prolly asking for way too much here.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default command button move worksheet from one workbook to another

Wouldn't it be easier just to copy the information

Update sList to reflect all the unlocked cells with information to be moved

Dim sList as String, Sh as Worksheet
Dim bkSrc as Workbook, bkDest as Workbook
Dim sh1 as Worksheet, fName as Variant
Dim bFound as Boolean, cell as Range
sList = "A1,B4,C11,F14,G3,R12"
set sh = Activesheet
set bksrc = sh.parent
fName = Application.GetOpenFileName()
if fName = False then Exit sub
set bkDest = Workbooks.Open(fName)

bFound = False
for each sh1 in bkDest.worksheets
if sh1.Range("B4").Value = "" then
bFound = True
for each cell in Sh.Range(sList)
sh1.Range(cell.Address).Value = cell.Value
next
exit for
end if
Next
if bFound then
sh.Range(sList).ClearContents
else
msgbox "No Openings in " & bkDest.name
end if
bkDest.Close SaveChanges:=True
bk.Src.Save

--
Regards,
Tom Ogilvy



"Qaspec" wrote in message
...
This will prolly go unanswered but..I have worksheets emp1 thru emp24. I
would like to place a command button on each sheet that when clicked will
allow me to move the sheet to another excel file that had tne same name

but
is in a different folder. In addition I'd like the worksheet to take the
place of one of the worksheets in the new file as long as the worksheet

does
not have a value in cell B4. So if file 1 emp5 is moved to file 2 it looks
for the first sheet with an empty B4 in file 2 and replaces it with the
worksheet from file1. So in theory file1 emp5 could become file2 emp8.I'd
also like file1 emp5 to retain its name but be clear of information in
unlocked cells (if it matters the worksheets are protected). Each employee
has his own worksheet but may switch teams at any time. Each team has it's
own file. I know I'm prolly asking for way too much here.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move and reset valuse using a command Button Chris Excel Discussion (Misc queries) 0 December 29th 09 11:54 PM
command button to move data dummy Excel Worksheet Functions 3 December 5th 09 06:44 PM
Command button moves even with don't move or resize checked. kelee Excel Discussion (Misc queries) 4 October 14th 08 01:11 PM
command button in excel will move when print. [email protected] Excel Discussion (Misc queries) 1 December 29th 04 03:53 PM
Why the command button in excel will move when print. TSH Excel Programming 1 November 24th 04 05:54 AM


All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"