Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro again..


Hi..

I have to write one macro which will add a button allowing Copy
function. This button should allow us to copy the whole contents of
some another Excel file (containing single tab) into the currently open
file.

For this I also need to add a search box which will allow me to search
and select the file in windows after clicking on the above button and
then proceed further..

Can anyone help me for this?

Thanks,
Sylvia


--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=500573

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro again..

option explicit
sub testme()
dim myFileName as variant
dim newwkbk as workbook
dim CurWks as worksheet

myfilename = application.getopenfilename("excel files, *.xls")
if myfilename = false then
exit sub
end if

set curwks = activesheet

set newwkbk = workbooks.open(filename:=myfilename)

newwkbk.worksheets(1).copy _
befo=curwks

newwkbk.close savechanges:=false

end sub

May get you started.



Sylvia wrote:

Hi..

I have to write one macro which will add a button allowing Copy
function. This button should allow us to copy the whole contents of
some another Excel file (containing single tab) into the currently open
file.

For this I also need to add a search box which will allow me to search
and select the file in windows after clicking on the above button and
then proceed further..

Can anyone help me for this?

Thanks,
Sylvia

--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=500573


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro again..


Hi Dave..

Thanks for your help. But it is creating a new worksheet. I want to
copy the content in the exesting worksheet only, after the existing
content. I dont want to add new worksheet. How to do that?

I tried newwkbk.Worksheets(1).Copy Destination:=CurWks

But its not working. :(

Can you please help me for this?

Thanks,
Sylvia


--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=500573

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro again..

option explicit
sub testme()
dim myFileName as variant
dim newwkbk as workbook
dim CurWks as worksheet
Dim destCell as range

myfilename = application.getopenfilename("excel files, *.xls")
if myfilename = false then
exit sub
end if

set curwks = activesheet
With curwks
set destCell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

set newwkbk = workbooks.open(filename:=myfilename)

newwkbk.worksheets(1).usedrange.cells.copy _
destination:=destcell

newwkbk.close savechanges:=false

end sub

This assumes that I can use column A to determine the next available row of the
current sheet.

Sylvia wrote:

Hi Dave..

Thanks for your help. But it is creating a new worksheet. I want to
copy the content in the exesting worksheet only, after the existing
content. I dont want to add new worksheet. How to do that?

I tried newwkbk.Worksheets(1).Copy Destination:=CurWks

But its not working. :(

Can you please help me for this?

Thanks,
Sylvia

--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=500573


--

Dave Peterson
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:00 PM.

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

About Us

"It's about Microsoft Excel"