Forum Discussion
Duplicate Row if any data in particular cell
You're giving us what I'd call a "procedural" or "mechanical" answer to my question of "What are you trying to accomplish?"
I know you want to compare two lists, a list of books from a library system with a list of books (the spreadsheet), but I'm trying to find out what it is that this multiplication of rows is going to do that can't be done with the data as it exists.
Said another way--or perhaps it's a different question--what kind of comparison are you trying to do that causes you to think you need multiple rows per book.
Said another way, what might the final output look like?
Try to answer those last two questions in plain ol' English, i.e., without reference to rows and columns in Excel. Don't try to do the Excelling for us; let us do that.
(For the record, these are the kinds of questions I'd be asking if we were sitting down face-to-face.)
The items were imported into a new system from the spreadsheet and some titles have the wrong barcode entirely.
We know this as when you search for some items with the book in front of you the barcode doesn't match, they are for a different item entirely. I checked the titles in question on the original spreadsheet and they are wrong there as well - so presumably it wasn't an error when the spreadsheet was mapped to the database.
I wish to scan the ISBN and barcode from each physical item into a file. This will give me the correct info.
I then wish to compare that to the system and original spreadsheet.
Because of multiple copies of items with the same ISBN I wanted one per row - I assumed it would be easier to compare the multiple copies by sorting by ISBN.
Sorry if this is too much info - I've been at this a while today and my head is fried!
- mathetesAug 16, 2023Gold Contributor
Sorry if this is too much info - I've been at this a while today and my head is fried!
I understand. Reading what you've written, my head is spinning. But I have a question, based on the following two statements:
I wish to scan the ISBN and barcode from each physical item into a file. This will give me the correct info.
I then wish to compare that to the system and original spreadsheet.Once you have the correct info, after scanning each physical item, what's the purpose of comparing with the system and the original spreadsheet? You have the correct info; why not stop there? What additional value is achieved by comparing the correct info with info you know not to be fully reliable?
- crankcallerAug 16, 2023Copper ContributorAs I typed my previous response I realised that myself. I would like to know if they are all wrong - or what percentage. If they are all wrong then a new load will be required which will cost money. If it's say 25% of items then staff can manually alter the records.
- mathetesAug 16, 2023Gold Contributor
So you seem to be suggesting that the records--official library records?--won't automatically get corrected by the scanning process; is that right? There still seem to be a lot of moving parts here, and it's difficult to get the full picture "remotely."
- OliverScheurichAug 16, 2023Gold Contributor
Sub barcodes() Dim i, j, k As Long j = Range("A" & Rows.Count).End(xlUp).Row For i = j To 2 Step -1 For k = 13 To 6 Step -1 If Cells(i, k).Value <> "" Then Cells(i + 1, 1).EntireRow.Insert Range(Cells(i + 1, 6), Cells(i + 1, 13)).Value = Range(Cells(i, 6), Cells(i, 13)).Value Range(Cells(i + 1, 1), Cells(i + 1, 5)).Value = Range(Cells(i, 1), Cells(i, 5)).Value Cells(i + 1, k).Clear Else End If Next k Next i End SubDoes this code return a result similar to what you are looking for when you run the macro in the attached file?
- crankcallerAug 16, 2023Copper ContributorI have switched off my laptop. But I will check this I the morning. Thank you very much.