Need to edit / correct code

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello JohnnyL
I have come across one problem in the Match Portal with Books code. When there is no GSTIN number in the other sheets (Purchases, Journal) in the last row but the other columns have data, the code is not shifting the row to the mismatched Sheet. Actually, it is not even taking into consideration that particular row and doing nothing.
First test the code as it is. I have given the wrong GSTIN number to the last row in Purchases and Journal. The 2 rows with the wrong GSTIN will display in the mismatched sheet.
Now delete the GSTIN number in the cell of the last row of both Purchases and Journal. This time it will not show in Mismatches nor Matched and not even in the combined portal sheet.
Likewise, if I delete the last 2 or more GSTIN numbers in the cell then all those rows need to display in the Mismatched sheet. which it is not.
I think the code is only taking the rows till the last GSTIN number.
Need your help to correct this.
One fault to rectify.xlsm
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The code is mostly using the xlUp technique of finding the last row and using the GSTIN column as the reference column.

If you are going to have lines that you want to take into account with a Blank GSTIN, you would need to find another way to work out what the last row is.
Is there another column that is guaranteed to always have data eg the Item column for all the sheets that xlUp on Column B ?
If so then simply looks for xlUp and switch where ever you see "B" on that line to "A".
There are I think 2 sheets that use column "A" but I don't think they are causing you and issue.
 
Upvote 0
I can't find column B xlup. What I found is already A.
Rich (BB code):
SourceLastRow = wsSource.Range("A" & Rows.Count).End(xlUp).Row                          ' Get last row used in column A of the source sheeet
 
Upvote 0
Rich (BB code):
Set wsSource = Sheets(SourceSheet)
Ws Source are all other sheets except
"Conditions", "2A", "Matched" and "Mismatches"
The code is mostly using the xlUp technique of finding the last row and using the GSTIN column as the reference column.

If you are going to have lines that you want to take into account with a Blank GSTIN, you would need to find another way to work out what the last row is.
Is there another column that is guaranteed to always have data eg the Item column for all the sheets that xlUp on Column B ?
If so then simply looks for xlUp and switch where ever you see "B" on that line to "A".
There are I think 2 sheets that use column "A" but I don't think they are causing you and issue.
 
Upvote 0
In your example in the initial post you referred to sheets (Purchases, Journal).
Both of those are using the code below to determine the last row.
Change that to "A" and see if that solves your issue.

Rich (BB code):
Sub GetDataFromDataSheet(DataWorkSheet As String)
'
    Dim ArrayColumn                 As Long, ArrayRow       As Long
    Dim DataLastColumn              As String, DataLastRow  As Long, DestinationStartRow    As Long
    Dim CorrectedDataArray          As Variant
    Dim DataSheetArray              As Variant
'
    With Sheets(DataWorkSheet)
        DataLastRow = .Range("B" & .Rows.Count).End(xlUp).Row                                       ' Get last row of the Data sheet column B
'
 
Last edited:
Upvote 0
Solution
In your example your initial post you referred to sheets (Purchases, Journal).
Both of those are using the code below to determine the last row.
Change that to "A" and see if that solves your issue.

Rich (BB code):
Sub GetDataFromDataSheet(DataWorkSheet As String)
'
    Dim ArrayColumn                 As Long, ArrayRow       As Long
    Dim DataLastColumn              As String, DataLastRow  As Long, DestinationStartRow    As Long
    Dim CorrectedDataArray          As Variant
    Dim DataSheetArray              As Variant
'
    With Sheets(DataWorkSheet)
        DataLastRow = .Range("B" & .Rows.Count).End(xlUp).Row                                       ' Get last row of the Data sheet column B
'
Ok. I am out. I will try it out once I reach home. Will update you.
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,124,996
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top