Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Formula to add cells from external file


Hi,

I'm trying to write a formula with VBA to add data from cells from a
external Excel file using the GetOpenFileName method.

So far I keep encountering syntax errors.

For example, I want the activecell formula to add (sum) data from a
external file Sheet2, cell AL23; Sheet2, cell AT17; Sheet2, cellAT24
etc.

Any help will be greatly appreciated, thanks

--
Bor
-----------------------------------------------------------------------
Borg's Profile: http://www.excelforum.com/member.php...fo&userid=3639
View this thread: http://www.excelforum.com/showthread.php?threadid=57427

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Formula to add cells from external file


This is kind of what the VBA code I'm trying:

Sub AutoPopulateTest()

MsgBox "IN THE NEXT DIALOG BOX," & (Chr(13)) & (Chr(13)) & _
"FIND THE EXCEL FILE & " & (Chr(13)) & (Chr(13)) & _
"DOUBLE-CLICK ON IT TO" & (Chr(13)) & (Chr(13)) & _
"AUTO-POPULATE THE TEST SHEET.", vbInformation

TEST = ActiveWorkbook.Name

'Get the Excel File
BookA = Application.GetOpenFilename("Excel Workbook (*.xls), *.xls")

If BookA < False Then
Workbooks.Open Filename:=BookA
End If

BookA = ActiveWorkbook.Name


Windows(TEST).Activate
Sheets("Sheet1").Range("C22").Select
Windows(BookA).Activate
Sheets("Sheet2").Select
ActiveCell.Formula = '=sum(Workbooks([BookA]).Worksheets_
("Sheet2").Range("AL23"),
Workbooks([BookA]).Worksheets("Sheet2").Range("AT17"),
Workbooks([BookA]).Worksheets("Sheet2").Range("AT24"))'
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

I realize it is not very good, but I needed some help. Thanks.


--
Borg
------------------------------------------------------------------------
Borg's Profile: http://www.excelforum.com/member.php...o&userid=36396
View this thread: http://www.excelforum.com/showthread...hreadid=574272

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
absolute cells when linking to an external file del Excel Discussion (Misc queries) 2 May 6th 09 07:07 PM
Inserting text from external file into cells. warirv63 Excel Discussion (Misc queries) 0 April 16th 08 07:27 AM
Formula to test for existence of external file Al at Novelis Excel Worksheet Functions 2 August 29th 06 01:13 AM
external database file into excel formula George Excel Worksheet Functions 0 April 17th 05 08:32 PM
How do I send some cells to an external text file? lothario[_2_] Excel Programming 1 October 12th 03 02:34 PM


All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"