I'm trying to develop a macro that will find the last row in column A (starting at row 7) check to see if there is content in both column A & B and if there isn't stop the macro. Thanks
I'm trying to develop a macro that will find the last row in column A (starting at row 7) check to see if there is content in both column A & B and if there isn't stop the macro. Thanks
will return the last row number with a value in it in column A.Please Login or Register to view this content.
will stop the macro.Please Login or Register to view this content.
Is this what you are after?
Test in atached file - runs with {CTRL} K
Message box added to help you see when macro exits
Please Login or Register to view this content.
Click *Add Reputation to thank those who helped you. Ask if anything is not clear
Maybe:
Please Login or Register to view this content.
Thanks to all for responding to my quest. I had thought it would be easy once I had this but it appears not to be the case.
Once I confirm the last cells in column A and B are not blank I wanted to call the followwing code.
But although it works with the code Kev has provided ( I changed the letters for numbers) it only checks it the once and then continues to add to the next row. Any suggestions?Please Login or Register to view this content.
What exactly are you trying to achieve?
Explain the whole thing
When should the macro continue checking?
When should it stop?
etc
Perhaps attach a workbook with before and after sheets
(Click reply, Go Advanced, look below for "Manage Attachments" etc to attach a workbook)
Kev, again thanks for coming back. In answer to your question; I have a form which I manually populate and then using a macro it copies the data across to a table. At the starrt of the macro I want to check to see if I've inadvertently added an ID number without its detail which is what your macro does. However it provided a msgbox so when I replaced the box with the code above it doesn't work as intended and I just keep adding ID numbers. I hope this answers the question. Thanks
Yes - my code will find the first incidence where both columnA and columnB are blank
- your code then adds 1 to the last found value in columnA
When you say "it doesn't work as intended" what exactly do you want to happen after VBA finds the 2 columns blank?
Kev, I have made changes to the macro you've provided and attached the file to show you what I hope to achieve. However, I not so sure the attachement has attached itself....but I'll find out in a minute
Is this what you want?
- test in attached workbook
Please Login or Register to view this content.
Kev, I'm sorry as I feel I'm imposing upon you now. The macro stills continues to add to Column A even though the last entry on column B is on row 10. I am expecting for the macro to add the value 4 to row 11 and if I run it again the macro stops. Thanks
Try this
- I think you are trying to insert a value in column A if there is already something in columnB and keep going until columnA has caught up with columnB
Please Login or Register to view this content.
Kev, we have gone this far and I need to get my point across, which obviously I'm failing big time.
The latest version of the macro appears ot do nothing.
I have retunred the file to try and show what results are expected. I am truely grateful for your help
Perhaps:
Could there be data missing in Column A and Column B would have data? Or will Column B always be the column with the data missing?Please Login or Register to view this content.
Last edited by JOHN H. DAVIS; 09-07-2017 at 02:12 PM.
tomorrow...
John, the missing data will always be in column B. I will try the code in the morning and feed back. Thanks
test in the attached workbook with {CTRL} k
- run in both sheet1 and sheet2
Please Login or Register to view this content.
John, have tested the code but I'm afraid still doesn't work. Regards
It can't be this simple.
Please Login or Register to view this content.
Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.
Mr B many thanks thats eacactly what I wanted - Thanks to all who contributed.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks