![]() |
Searching for blank cell and populating based on previous data
Good day,
I've spent a bit of time browsing for this subject, but I'm a still a little unclear after reading some of the posts. What I am trying to accomplish via a macro: Given a layout (A, B, C... are the columns) A B C D Red Steel Rolled Packaged Cast Bulk Extruded Bulk I am trying to figure out a macro which will recognize that cells A2, A3 are blank and fill those particular cells with the previous given value (in this case "Red"). The same for the cells B2, B3 filled with "Steel". Basically, trying to fill in the blanks so that I can insert it into a database. I've tried messing around with: Dim Rcell as range For Each Rcell in Range("A:A") If Rcell.value = "" Then Rcell = Rcell.offset(-1, 0) Else End If Next I am getting good results from that code, BUT I cannot figure out how the macro will know to stop after it has run through all of my data. I'm only working with a few hundred rows, but the number of rows is not consistent with each report I'm trying to convert this way. The macro just keeps running until it reaches row 65536. Any ideas? I thank you very much for your time and any support you can provide. |
Searching for blank cell and populating based on previous data
See
http://www.contextures.com/xlDataEntry02.html -- Regards Ron de Bruin http://www.rondebruin.nl "AZ Analog" wrote in message ... Good day, I've spent a bit of time browsing for this subject, but I'm a still a little unclear after reading some of the posts. What I am trying to accomplish via a macro: Given a layout (A, B, C... are the columns) A B C D Red Steel Rolled Packaged Cast Bulk Extruded Bulk I am trying to figure out a macro which will recognize that cells A2, A3 are blank and fill those particular cells with the previous given value (in this case "Red"). The same for the cells B2, B3 filled with "Steel". Basically, trying to fill in the blanks so that I can insert it into a database. I've tried messing around with: Dim Rcell as range For Each Rcell in Range("A:A") If Rcell.value = "" Then Rcell = Rcell.offset(-1, 0) Else End If Next I am getting good results from that code, BUT I cannot figure out how the macro will know to stop after it has run through all of my data. I'm only working with a few hundred rows, but the number of rows is not consistent with each report I'm trying to convert this way. The macro just keeps running until it reaches row 65536. Any ideas? I thank you very much for your time and any support you can provide. |
All times are GMT +1. The time now is 11:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com