carmenlisa
Technical User
I am stuck on an issue that revolves around the difference between a null cell versus an empty cell in Excel and Access.
The scenario is that we have people doing data entry in many tabs in an
Excel file, data which will then be imported into Access. In many of the tabs, we do not know in advance how many rows of data will be entered. The people are gathering information about buildings and every building is obviously different.
I must deal with a situation where the data input tabs are laid out in a manner that does not allow for importing into Access. So I added a somewhat matching set of tabs that rearrange the data in a way that will allow Access to read the data. That is, the data must have field names across the top row with the data in rows below it. And, of course, I often do not know exactly how many rows of data there will be.
I did this with formulas. In essence, I get data that in some cases needs to be transposed from vertical to horizontal layout. In other cases I need to get the data from a specific place in a tab where it is located in the middle of a lot of other clutter.
I have no options that allow me to change the layout in the data input tabs. And I have no option to arrange for the data to be input directly into Access, which would be my first choice.
I must deal with the data as it is currently laid out in the data input tabs in Excel.
So, here is what I have done thus far. I created a second set of tabs in Excel, using formulas that draw from the data input tabs, but which lay out the data in the required format of a header row for field names and rows of data below it. That is, the result is that the data looks like an Access table. I enclosed every formula in an IF statement that leaves the cells blank if the originating cell in the input tab was blank. The formula, roughly, is: =IF(OriginatingCell = “”,””, OriginatingCell).
I then run a macro that converts all formulas to values, leaving any unneeded/unused cells empty.
The problem in my process is that these cells that I designated as “” and then converted to values are not null and Access wants to import them all as blank entries rather than ignoring them. And we end up with lots of empty rows of data in Access. (We need to allow for receiving maybe as many as 20 rows of data in a tab, but in most cases end up with only a couple rows of data).
If I were doing this as a one time thing, I would just go into each tab, find the last row of data and deleted about 50 rows directly below the last line of data and be done with the problem. But there are too many spreadsheets and too many tabs per spreadsheet for this to be feasible, doing it all manually. Finding the last row of data with a macro is too prone to error. If there were a column where I absolutely positively knew would never be empty for a record, I assume that I could do the equivalent of End-DownArrow and deleted 50 rows below that. But in my experience, any field that “always” must have an entry, sooner or later, does not have an entry for what seemed like a valid reason to the guy making the entries, and then we wipe out a whole lot of data that we needed.
So, is there a way to convert cells that are empty into null cells? I would love, in code, to do the equivalent of:
For cells A1100, IF cell is empty, then cell becomes null, else do nothing.
I am self-taught in VBA and only so-so in it. I understand loops and IF statements, so I can do a lot with very limited knowledge, but am clueless with the less obvious and less common aspects of VBA.
Is there a way to do the above (making a cell be null) in Excel? Does anyone know of any other options that might work? Remembering that I have absolutely no options in terms of changing the data entry tabs or switching to Access for the data entry?
I understand that I could create queries in Access to delete all blank records, but that can be pretty clumsy and seems like not a great way to fix the problem.
I want to thank all in advance for any advice/solutions I am given.
The scenario is that we have people doing data entry in many tabs in an
Excel file, data which will then be imported into Access. In many of the tabs, we do not know in advance how many rows of data will be entered. The people are gathering information about buildings and every building is obviously different.
I must deal with a situation where the data input tabs are laid out in a manner that does not allow for importing into Access. So I added a somewhat matching set of tabs that rearrange the data in a way that will allow Access to read the data. That is, the data must have field names across the top row with the data in rows below it. And, of course, I often do not know exactly how many rows of data there will be.
I did this with formulas. In essence, I get data that in some cases needs to be transposed from vertical to horizontal layout. In other cases I need to get the data from a specific place in a tab where it is located in the middle of a lot of other clutter.
I have no options that allow me to change the layout in the data input tabs. And I have no option to arrange for the data to be input directly into Access, which would be my first choice.
I must deal with the data as it is currently laid out in the data input tabs in Excel.
So, here is what I have done thus far. I created a second set of tabs in Excel, using formulas that draw from the data input tabs, but which lay out the data in the required format of a header row for field names and rows of data below it. That is, the result is that the data looks like an Access table. I enclosed every formula in an IF statement that leaves the cells blank if the originating cell in the input tab was blank. The formula, roughly, is: =IF(OriginatingCell = “”,””, OriginatingCell).
I then run a macro that converts all formulas to values, leaving any unneeded/unused cells empty.
The problem in my process is that these cells that I designated as “” and then converted to values are not null and Access wants to import them all as blank entries rather than ignoring them. And we end up with lots of empty rows of data in Access. (We need to allow for receiving maybe as many as 20 rows of data in a tab, but in most cases end up with only a couple rows of data).
If I were doing this as a one time thing, I would just go into each tab, find the last row of data and deleted about 50 rows directly below the last line of data and be done with the problem. But there are too many spreadsheets and too many tabs per spreadsheet for this to be feasible, doing it all manually. Finding the last row of data with a macro is too prone to error. If there were a column where I absolutely positively knew would never be empty for a record, I assume that I could do the equivalent of End-DownArrow and deleted 50 rows below that. But in my experience, any field that “always” must have an entry, sooner or later, does not have an entry for what seemed like a valid reason to the guy making the entries, and then we wipe out a whole lot of data that we needed.
So, is there a way to convert cells that are empty into null cells? I would love, in code, to do the equivalent of:
For cells A1100, IF cell is empty, then cell becomes null, else do nothing.
I am self-taught in VBA and only so-so in it. I understand loops and IF statements, so I can do a lot with very limited knowledge, but am clueless with the less obvious and less common aspects of VBA.
Is there a way to do the above (making a cell be null) in Excel? Does anyone know of any other options that might work? Remembering that I have absolutely no options in terms of changing the data entry tabs or switching to Access for the data entry?
I understand that I could create queries in Access to delete all blank records, but that can be pretty clumsy and seems like not a great way to fix the problem.
I want to thank all in advance for any advice/solutions I am given.