CSV Import (Done) - Find Title, Compare and adjust Inventory

Dennis88

New Member
Joined
Jan 11, 2016
Messages
4
Dear All,

we are working on an inventory file and would like to compare daily sales, which come from a CSV import (thats alrady working just fine), to our inventory.


The CSV Import looks as follows (Sheetname "Afterbuy Einlesen"):
RechnungsnummerRechnungsdatumAmount
Titel
Artikelnummer
4959205.01.20161
5x MAXELL CR2032 LITHIUM BATTERIEN BATTERY KNOPFZELLE 3V --- OVP --- NEU2,0146E+11

<tbody>
</tbody>

<tbody>
</tbody>


These daily sells are saved into a help sheet, which subsequently shall be compared to our investory and the amount of daily sold items shall be substracted from the inventory.
The inventory data is stored on our "Lager" sheet, which looks as follows:


IDErstellt amArtikel Nr.Hersteller Nr.
Titel
HerstellerInventory
StatusBestand min.Melde-BestandEinheitLagerort
15105.01.20161515x MAXELL CR2032 LITHIUM BATTERIEN BATTERY KNOPFZELLE 3V
1010Lager 1

<tbody>
</tbody>


In such a case the code shall first find the correct line item in our inventory sheet (5x MAXCELL CR2032) and then just the sold amount from our imported CSV Sheet explained above. In that case -1


Our current approach is to work via a VLOOKUP and row identifier, however we think it would be easier to save the String and identify the row directly.

Every idea or approach is highly appreciated.

Thanks!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This is the CSV Import Code that we are using at the moment (the for loop marks the framework for the code)
Code:
Sub Einlesen()

  Dim strFileName As String, arrDaten, arrTmp, lngR As Long, lngLast As Long
  Const cstrDelim As String = "," 'Trennzeichen
  
  With Application.FileDialog(msoFileDialogFilePicker)
    .AllowMultiSelect = False
    .Title = "Datei wählen"
    .InitialFileName = "d:\HBZ\Energieausweise\Berechnungsgrundlagen\*.csv"  'Pfad anpassen
    .Filters.Add "CSV-Dateien", "*.csv", 1
    If .Show = -1 Then
      strFileName = .SelectedItems(1)
    End If
  End With
  
  Sheets("Afterbuy Einlesen").Select

'Select Afterbuy File
    
If strFileName <> "" Then
    Application.ScreenUpdating = False
    Open strFileName For Input As #1
    arrDaten = Split(Input(LOF(1), 1), vbCrLf)
    Close #1
    For lngR = 0 To UBound(arrDaten)
      arrTmp = Split(arrDaten(lngR), cstrDelim)
      If UBound(arrTmp) > -1 Then
                With ActiveSheet
                        lngLast = .Cells(Rows.Count, 1).End(xlUp).Row + 1
                        lngLast = Application.Max(lngLast, 0)
                        .Cells(lngLast, 1).Resize(, UBound(arrTmp) + 1) _
                          = Application.Transpose(Application.Transpose(arrTmp))
                        .Cells(lngLast, 11) = Mid(strFileName, InStrRev(strFileName, "\") + 1)
               End With
        
      End If
    Next lngR
  End If
  
' Search and replace ("")
  
    Range("A1:AL2500").Select
    Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False
    
' Sear for sold items and adjust value in warehouse
 
 For i = 0 To lngLast
 
 
 
 
 Next i
 
 
End Sub




The explained part above is missing and shall be added at the bottom.

Thanks!
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,215,987
Messages
6,128,134
Members
449,425
Latest member
NurseRich

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