T
Tony in Michigan
Hello,
I have multiple weekly part change spreadsheets that I need to import into
access for manipulation.
There are four columns
Description: Short text sentence
New number: parts number/s in prefix-base-suffix form, cell contains from
one to the theoretical limit of the cell. They are seperated by spaces,
sometimes <CR> or other "hard" seperator
Supplier code: 5 char code
Supplier name: Short text sentense.
I need to import these spreadsheets into access, Explode the new number
field, placing one part per record and copy the other three fields to the new
record.
A former co-worker wrote VBA in excel to do this, for space seperated parts.
unfortunatly, he is gone, and I still need to bring it into access to
aggregate, clean and query against other data. How would I do this in access?
Below is the excel code.
Function Explode()
Dim strRow As String
Dim strNewNumber1 As String
Dim strNewNumber2 As String
Dim intPosition As Integer
strRow = 2
Do Until Range("B" & strRow).Value = ""
Range("B" & strRow).Select
strNewNumber1 = Trim(Range("B" & strRow).Value)
If InStr(strNewNumber1, " ") > 0 Then
intPosition = InStr(strNewNumber1, " ")
strNewNumber2 = Left(strNewNumber1, intPosition - 1)
strNewNumber1 = Trim(Mid(strNewNumber1, intPosition))
Rows(strRow & ":" & strRow).Select
Selection.Copy
Rows(strRow + 1 & ":" & strRow + 1).Select
Selection.Insert Shift:=xlDown
Range("B" & strRow).Value = strNewNumber2
Range("B" & strRow + 1).Value = strNewNumber1
End If
strRow = strRow + 1
Loop
End Function
I have multiple weekly part change spreadsheets that I need to import into
access for manipulation.
There are four columns
Description: Short text sentence
New number: parts number/s in prefix-base-suffix form, cell contains from
one to the theoretical limit of the cell. They are seperated by spaces,
sometimes <CR> or other "hard" seperator
Supplier code: 5 char code
Supplier name: Short text sentense.
I need to import these spreadsheets into access, Explode the new number
field, placing one part per record and copy the other three fields to the new
record.
A former co-worker wrote VBA in excel to do this, for space seperated parts.
unfortunatly, he is gone, and I still need to bring it into access to
aggregate, clean and query against other data. How would I do this in access?
Below is the excel code.
Function Explode()
Dim strRow As String
Dim strNewNumber1 As String
Dim strNewNumber2 As String
Dim intPosition As Integer
strRow = 2
Do Until Range("B" & strRow).Value = ""
Range("B" & strRow).Select
strNewNumber1 = Trim(Range("B" & strRow).Value)
If InStr(strNewNumber1, " ") > 0 Then
intPosition = InStr(strNewNumber1, " ")
strNewNumber2 = Left(strNewNumber1, intPosition - 1)
strNewNumber1 = Trim(Mid(strNewNumber1, intPosition))
Rows(strRow & ":" & strRow).Select
Selection.Copy
Rows(strRow + 1 & ":" & strRow + 1).Select
Selection.Insert Shift:=xlDown
Range("B" & strRow).Value = strNewNumber2
Range("B" & strRow + 1).Value = strNewNumber1
End If
strRow = strRow + 1
Loop
End Function