Solved

Add the file name and date

Posted on 2011-02-28
2
299 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
Comment Utility
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
Comment Utility
Great!

Thanks for the info.
JP
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now