Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
copy and paste it in a new sheet with sheet name as a1 value
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
vicky  
View profile  
 More options Nov 9, 6:54 pm
Newsgroups: microsoft.public.excel.programming
From: vicky <vimalbarl...@gmail.com>
Date: Sun, 8 Nov 2009 23:54:50 -0800 (PST)
Local: Mon, Nov 9 2009 6:54 pm
Subject: copy and paste it in a new sheet with sheet name as a1 value
 I have many work books in one folder . want to copy data from every
workbook  to
the resultworkbook and the sheet names should be of  a1 value .

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel  
View profile  
 More options Nov 9, 10:43 pm
Newsgroups: microsoft.public.excel.programming
From: joel <joel.41d...@thecodecage.com>
Date: Mon, 9 Nov 2009 11:43:10 +0000
Local: Mon, Nov 9 2009 10:43 pm
Subject: Re: copy and paste it in a new sheet with sheet name as a1 value

Try the code below.  Change the FOLDER name as required.  Make sure you
have a backslash at the end of the folder name.  The Macro will give you
an error if the data in cell A1 is not a valid name for a worksheet.
worksheet names can't be nothing and can't contain certain characters.

Sub copybooks()

Folder = "C:\temp\"
FName = Dir(Folder & "*.xls")
Do While FName <> ""
'open workbook
Set bk = Workbooks.Open(Folder & FName)
For Each sht In bk.Worksheets
With ThisWorkbook
sht.Copy after:=.Sheets(.Sheets.Count)
ActiveSheet.Name = sht.Range("A1")
End With
Next sht

bl.Close savechanges:=False
FName = Dir()
Loop

End Sub

--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=152271

[url=&quot;http://www.thecodecage.com"]Microsoft Office Help[/url]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vicky  
View profile  
 More options Nov 9, 11:21 pm
Newsgroups: microsoft.public.excel.programming
From: vicky <vimalbarl...@gmail.com>
Date: Mon, 9 Nov 2009 04:21:03 -0800 (PST)
Local: Mon, Nov 9 2009 11:21 pm
Subject: Re: copy and paste it in a new sheet with sheet name as a1 value
thanks a lot joel...

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel  
View profile  
 More options Nov 9, 11:40 pm
Newsgroups: microsoft.public.excel.programming
From: joel <joel.41d...@thecodecage.com>
Date: Mon, 9 Nov 2009 12:40:41 +0000
Local: Mon, Nov 9 2009 11:40 pm
Subject: Re: copy and paste it in a new sheet with sheet name as a1 value

I have a small typo

from
bl.Close savechanges:=False
to
bk.Close savechanges:=False

I didn't test this line.  the rest of the code was tested.

--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=152271

[url=&quot;http://www.thecodecage.com"]Microsoft Office Help[/url]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vicky  
View profile  
 More options Nov 10, 2:27 am
Newsgroups: microsoft.public.excel.programming
From: vicky <vimalbarl...@gmail.com>
Date: Mon, 9 Nov 2009 07:27:35 -0800 (PST)
Local: Tues, Nov 10 2009 2:27 am
Subject: Re: copy and paste it in a new sheet with sheet name as a1 value
i have tried this code as wel . its working .... thamks joel for
taking time to answer my questions....

Set NewWkb = ThisWorkbook
MyPath = "C:\Documents and Settings\vb\"
ChDir MyPath
TheFile = Dir("*.xls")
Do While TheFile <> ""
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
Set obj = wb.Sheets(1)
obj.Cells.Copy
NewWkb.Sheets.Add before:=NewWkb.Sheets(NewWkb.Sheets.Count)
sht.Copy after:=.Sheets(.Sheets.Count)
With NewWkb.ActiveSheet
.Range("a1").PasteSpecial xlPasteValues
.Name = obj.Range("a1").Value
End With
obj.Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ActiveSheet.Name = obj.Range("A1")
wb.Close
TheFile = Dir
Application.CutCopyMode = False

Loop


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google