Forum Discussion
Need Help Please!!
- Aug 30, 2022
Sub DNO() Dim i As Long Dim k As Long Dim l As Long l = Range("A" & Rows.Count).End(xlUp).Row k = 2 Worksheets("DNO").Range("A2:AX1048576").Clear For i = 2 To l Select Case Cells(i, 51).Value Case Is = "DNO" Range(Cells(i, 1), Cells(i, 50)).Copy Destination:=Worksheets("DNO").Cells(k, 1) k = k + 1 End Select Next i End SubMaybe with this code. In the attached file you can click the button in cell BA2 to run the code. In column AY you can enter "DNO" to copy the row to the designated sheet "DNO". I've entered random numbers in columns A to AX for this example.
OMG, thank you so much for working on this. You are obviously way smarter than I am, as i was hoping this was going to be a simple, or not so simple formula. This being said, I know zero about coding or anything remotely close to it but I am extremely advanced when is comes to formulas. , I did open the file you kindly made for me, but not too sure what to do with it or even what to do with the code you wrote for me in the above answer. When i clicked on the blue button in BA2 its a non-clickable button.
I feel bad and i'm so sorry to be difficult.
Thank you,
Steph
If there is a warning when you open the file you have to enable the content in order to run the macro. You would have to click the button "enable content" ("Inhalt aktivieren" in german) in this case. Then the button in cell BA2 should work.
I've tried to make an example according to your requirement. In the main sheet there are 50 columns and 200 rows of random data. You can add as many rows as required. Assume that the data in row 10 is "DNO" data. You can enter "DNO" in cell AY10 and click the button in cell BA2. The macro then clears all the data in sheet "DNO" and copies the data from row 10 of the main sheet to the "DNO" sheet. You don't have to change / adapt the code for this. Of course you can copy as many rows as you want at the same time.
- Steph_VAug 30, 2022Copper ContributorOliverScheurich
Perfect and makes sense, I think. I do have a few more questions though. Again, thank you for your time.
1. How do I copy it into my existing sheet?
2. Where do I copy it into my existing sheet?
3. I enabled the warning the first time I opened the workbook, but once I closed it and reopened it, it no longer gives me the warning. Either time with the warning and without the warning, the button still does not work.- Steph_VAug 30, 2022Copper Contributor
This is a screenshot of me copying and pasting it into the macro screen. When I run it, it doesn't work. Is there something else that I need to do?
- OliverScheurichAug 30, 2022Gold Contributor
Besides the missing "Option explicit" i can't tell why it doesn't work.
Does the code return an error message if you run it (with F5)? If there isn't an error message then the code runs until the end. Do you run the macro when the main sheet is selected and did you enter "DNO" in any cells in column AY? If so the respective rows should be copied to the "DNO" sheet.
If this still doesn't work maybe you want to attach your file without sensitive data.