Use Dmax In Vba
Aug 16, 2007I understand that you can use the DMAX function within vba code. I am trying to do this, but don't seem to be able to find an answer. I am formatting data in order for it to be uploaded into a programme called 'Holebase'. The following code loops through each sheet in the workbook, includes the data in a named range, sets up the sheet ready to calculate the DMAX function, and finally adds the dmax function. I am having trouble inserting the DMAX formula.
Sub maxLifData()
' for each worksheet in the workbook, do dmax formulae and add results to new sheet. bhole id on left, depth across top.
Dim ws As Worksheet
Dim wsName() As String
Dim i As Integer
Dim mCount As Integer
Dim nr1 As Range
Dim nr2 As Range
Dim head1 As String
Dim head2 As String
'Dim dMaxf As String
Dim frange As Range
head1 = "STCN_DPTH"
head2 = "STCN_FFD"
Set frange = Range("G3")
'dMaxf = "=DMAX(" & wsName(i) & ",D2," & frange & ":" & frange.Offset(1, 1) & ")"........................