VBA, pulling values together to do a comparison

  • Re: VBA, pulling values together to do a comparison


    That suggests it's not finding the value. When it errors, debug and hover over the coloured line and see what the value or 'r' is. I thought you said the tables were identical? If not, perhaps it's not the 4th column.

  • Re: VBA, pulling values together to do a comparison


    Quote from StephenR;774460

    That suggests it's not finding the value. When it errors, debug and hover over the coloured line and see what the value or 'r' is. I thought you said the tables were identical? If not, perhaps it's not the 4th column.



    Ah I see , that value that r equals does not exist in one of the workbooks, is there a way of identifying these as N/A's in the master sheet?

  • Re: VBA, pulling values together to do a comparison


    Adjust what you want to show as N/A. (By the way, no need to quote posts in your replied.)

  • Re: VBA, pulling values together to do a comparison


    Get an error on


    Code
    .Range("D" & Rows.Count).End(xlUp)(2).Value = r.Offset(, -3).Value - rWB2.Cells(n, 1).Value


    The previous code worked better and gave results, this one kind of messes up.

  • Re: VBA, pulling values together to do a comparison


    I can only go on the information you provide and I do not intend to spend my time trying to figure out what your files may or may not look like. Post a representative file if you want further help.

  • Re: VBA, pulling values together to do a comparison


    Right, try this. The delimiting bit got lost in the last couple of amendments.

  • Re: VBA, pulling values together to do a comparison


    Hi Steven, thanks it works great!!
    Is there ways to skip errors such as not clicking any files in the picker ? This is just bonus really, you solved the answer.

  • Re: VBA, pulling values together to do a comparison


    You could add a line in this section so that if fewer than two files are picked the sub ends

    Code
    With Application.FileDialog(msoFileDialogOpen)
            .AllowMultiSelect = True
            .Show
            If .SelectedItems.Count < 2 Then Exit Sub
            Workbooks.OpenText Filename:=.SelectedItems(1), DataType:=xlDelimited, Other:=True, OtherChar:="|"
            Set wb1 = ActiveWorkbook
            Workbooks.OpenText Filename:=.SelectedItems(2), DataType:=xlDelimited, Other:=True, OtherChar:="|"
            Set wb2 = ActiveWorkbook
        End With
  • Re: VBA, pulling values together to do a comparison


    Nice! works awesome! So before would it work with multiple files?



    Also what if I want to close workbooks without saving after the reconciliation is complete?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!