Solved

Add the file name and date

Posted on 2011-02-28
2
311 Views
Last Modified: 2012-06-27
Looking to add the file name to cell B2, from the list that was selected; and, the date and time on cell C3.  And also, when the data gets copied over, to copy "only" values and formats.

Thanks,
JP


Continuation from:  http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26853498.html#a35001118   Select-from-open-workbooks.xls
0
Comment
Question by:easycapital
2 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 35001696
Hi JP,

Here is an update for your userform code

Private Sub btnOK_Click()
On Error Resume Next

With ActiveSheet
    .Range("B5:D34").ClearContents
    Workbooks(Me.cbWbks.Value).Sheets("YTD").Range("A1:C30").Copy
    .Range("B5:D34").PasteSpecial Paste:=xlPasteValues
    .Range("B5:D34").PasteSpecial Paste:=xlPasteFormats
    
    .[b2] = Me.cbWbks.Value
    .[c3] = Now
End With

If Err <> 0 Then MsgBox "Sheet YTD not found in workbook " & Me.cbWbks.Value

Unload Me
End Sub


Private Sub UserForm_Initialize()
Dim wbk As Workbook

For Each wbk In Application.Workbooks
    Debug.Print wbk.Name & "{" & wbk.IsAddin
    If wbk.IsAddin = False Then Me.cbWbks.AddItem (wbk.Name)
Next

End Sub

Open in new window


FYI, if you use the ask a related question button, all experts previously involved in the question get notified automatically.

Thomas
0
 

Author Closing Comment

by:easycapital
ID: 35001906
Great!

Thanks for the info.
JP
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question