Click here to Skip to main content
16,006,001 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: _crtisvalidheappointer Pin
Dave Kreskowiak23-Mar-04 7:19
mveDave Kreskowiak23-Mar-04 7:19 
GeneralRe: _crtisvalidheappointer Pin
BlackDice23-Mar-04 7:27
BlackDice23-Mar-04 7:27 
GeneralRe: _crtisvalidheappointer Pin
Dave Kreskowiak23-Mar-04 9:01
mveDave Kreskowiak23-Mar-04 9:01 
GeneralRe: _crtisvalidheappointer Pin
BlackDice23-Mar-04 9:18
BlackDice23-Mar-04 9:18 
GeneralRe: _crtisvalidheappointer Pin
Dave Kreskowiak23-Mar-04 9:28
mveDave Kreskowiak23-Mar-04 9:28 
GeneralRe: _crtisvalidheappointer Pin
BlackDice23-Mar-04 9:30
BlackDice23-Mar-04 9:30 
GeneralRe: _crtisvalidheappointer Pin
Dave Kreskowiak23-Mar-04 11:35
mveDave Kreskowiak23-Mar-04 11:35 
GeneralExcel VBA - Multi column search and compare, with Refresh Pin
luxcs23-Mar-04 3:48
luxcs23-Mar-04 3:48 
Hi
Hopefully someone can help me with this problem.

I have a 3 page workbook (report,data1,data2).
data1 and data2 are loaded as External Data from 2 csv files and are updated at 10 minute intervals. Both sheets have the same layout -:
Col A = date (i.e. 12-DEC-04) (as string)
Col B = reference (i.e. ABC1234) (as string)
Col C = value1 (as integer)
Col D = value2 (as integer)
Col E = value3 (as integer)

The report page has 3 columns.
Col A = date (as Date)
Col B = reference (as string)
Cols C - F = various values
Col G = valtotal (as integer)

I've written a function that takes in 4 parameters (ref,date,page,reqcol).
"page" sets which of the sheets is used for the info (data1 or data2).
"Reqcol" sets which column from the data sheet is reqd.

(e.g. Cell G4 on the report might be =vallookup(G1,A1,"data2","E"))

This has to loop over the data checking all references, and if it finds a match then check the date. If both match, it returns the value in column (reqcol).

The data size is not known until the data is refreshed (cell A1 contains the number of rows).
A variable, 'lastrow', is used as the number of rows and a number of loops is performed.

The function appears to work sometimes, but other times won't work - on the same data!
Also, I need to have an easy way to refresh the values returned by the funcion on the report page without having to hit 'Enter' on each cell.

Here is the function as it stands......

Public Function vallookup(ref As String, dateref As Date, page As String, reqcol As String)<br />
    'Activate correct page sheet<br />
    Worksheets(page).Activate<br />
    'Get size of dataset<br />
    lastrow = Worksheets(page).Cells(2, "A").Value<br />
    'Loop data<br />
    For a = 1 To lastrow<br />
        If (UCase(ref) = UCase(Worksheets(page).Cells(a, "B").Value)) Then<br />
            If (dateref = DateValue(Worksheets(page).Cells(a, "A").Value)) Then<br />
                vallookup = Worksheets(page).Cells(a, reqcol).Value<br />
            End If<br />
        End If<br />
    Next a<br />
End Function<br />
<br />
<br />
Sub Refresh()<br />
    'Attempt at a Refresh function<br />
        Worksheets("report").Calculate<br />
End Sub

GeneralRequest (Reference to) other page Pin
Aizupis23-Mar-04 3:38
Aizupis23-Mar-04 3:38 
GeneralRe: Request (Reference to) other page Pin
Dave Kreskowiak23-Mar-04 4:20
mveDave Kreskowiak23-Mar-04 4:20 
GeneralRe: Request (Reference to) other page Pin
Michael Flanakin23-Mar-04 12:22
Michael Flanakin23-Mar-04 12:22 
GeneralRe: Request (Reference to) other page Pin
Dave Kreskowiak23-Mar-04 14:14
mveDave Kreskowiak23-Mar-04 14:14 
GeneralRe: Request (Reference to) other page Pin
Michael Flanakin23-Mar-04 14:22
Michael Flanakin23-Mar-04 14:22 
GeneralHelp Needed Pin
hmssws23-Mar-04 2:37
hmssws23-Mar-04 2:37 
GeneralRe: Help Needed Pin
Dave Kreskowiak23-Mar-04 4:10
mveDave Kreskowiak23-Mar-04 4:10 
Generaldisplay checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 0:30
Chrissy Callen23-Mar-04 0:30 
GeneralRe: display checkbox in columns of datagrid Pin
Syed Abdul Khader23-Mar-04 2:09
Syed Abdul Khader23-Mar-04 2:09 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 2:13
Chrissy Callen23-Mar-04 2:13 
GeneralRe: display checkbox in columns of datagrid Pin
Syed Abdul Khader23-Mar-04 2:19
Syed Abdul Khader23-Mar-04 2:19 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 2:57
Chrissy Callen23-Mar-04 2:57 
GeneralRe: display checkbox in columns of datagrid Pin
Syed Abdul Khader23-Mar-04 3:04
Syed Abdul Khader23-Mar-04 3:04 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 3:29
Chrissy Callen23-Mar-04 3:29 
GeneralRe: display checkbox in columns of datagrid Pin
roshanak23-Mar-04 22:06
roshanak23-Mar-04 22:06 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 23:23
Chrissy Callen23-Mar-04 23:23 
GeneralPlease help me! _event handeling Pin
xstoneheartx22-Mar-04 23:37
xstoneheartx22-Mar-04 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.