Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro to open a file and I want to enter the file name from which
macro is run to a cell in opened file. If I open abc.xls from file xyz.xls, then I want value of cell F2 in abc.xls to be xyz |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim sFile As String Dim ws As Worksheet Dim wb As Workbook sFile = "C:\Documents and Settings\Owner\My Documents\abc.xls" On Error Resume Next Set wb = Workbooks.Open(sFile) On Error GoTo 0 If wb Is Nothing Then MsgBox "File not found" & vbCr & sFile Exit Sub End If Set ws = wb.Worksheets("Sheet2") ws.Range("F2") = ThisWorkbook.Name ws.Activate End Sub Regards, Peter T "Kashyap" wrote in message ... I have a macro to open a file and I want to enter the file name from which macro is run to a cell in opened file. If I open abc.xls from file xyz.xls, then I want value of cell F2 in abc.xls to be xyz |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Workbooks.Open Filename:= _
"C:\Users\OssieMac\Documents\Excel\Test Macros\ABC.xls" ActiveWorkbook.Sheets("Sheet1").Range("F2") = ThisWorkbook.Name -- Regards, OssieMac "Kashyap" wrote: I have a macro to open a file and I want to enter the file name from which macro is run to a cell in opened file. If I open abc.xls from file xyz.xls, then I want value of cell F2 in abc.xls to be xyz |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Browse For a File or Path and enter in a cell | Excel Discussion (Misc queries) | |||
Enter multiple numbers in a cell so total shows when enter keypres | Excel Worksheet Functions | |||
How do I enter a wave sound file into an excel cell? | Excel Discussion (Misc queries) | |||
how formatting CSV file to get alt-enter text in one cell | Excel Programming | |||
embed <alt<enter for multiline cell in a CSV file | Excel Programming |