Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMPORTING DATA

Status
Not open for further replies.

mmartens

Mechanical
Joined
Jul 17, 2001
Messages
24
Location
CA
This is what I am doing I am importing data from a file to a work sheet which get the name of the file. I want to determine the max value in the colume from that work sheet and put it in the cell of an other work sheet which name stays the same.

Dim intlastrow As Integer
Dim FirstSheetName As String

' determine the total number of work sheet in the work book
LastWorkSheet = Worksheets.Count
'OPENS_A_DIALOGUE_BOX_TO_OPEN_THE_DATA_FILE()
Application.Dialogs(xlDialogOpen).Show ("*.out")
'Move the worksheet to the PipLin Report.xls file into the last worksheet place
FirstSheetName = Sheets(1).Name
Sheets(FirstSheetName).Select
Sheets(FirstSheetName).Move After:=Workbooks("Test Report Round.xls").Sheets(LastWorkSheet)

' Selecting the a column we finded the number of rows in it.
' The last row number is entered into varable name.
Range("A3").Select
Selection.End(xlDown).Select
intlastrow = ActiveCell.Row

' MOVE TO THE INFORMATION SHEET IN ORDER TO PUT IN INFORMATION
' This sheet name stays the same
Sheets("TEST INFORMATION SHEET").Select
Range("D22").Select ' this cell is in the work sheet "TEST INFORMATION SHEET"
ActiveCell.Formula = "=MAX(test!A3:A500)"
'This is the problem line
'(1) I do not know the name of the data sheet EXAMPLE HERE (test)
'(2) I do not know how long colume A is going to be

This is what I have tryed thinking that it would work but it did not

ActiveCell.Formula = " = MAX(INDIRECT(FirstSheetName)"!A3:A" & intlastrow)"

Any help would be great I am at the end of my rope...



 
Try this:

ActiveCell.Formula = "= MAX(" & FirstSheetName & "!A3:A" & intLastRow & ")"
 
Thanks vhphan

It works great thanks

mmartens
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top