Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add the file name and date

Posted on 2011-02-28
2
Medium Priority
?
325 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

877 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