Showing posts with label blank. Show all posts
Showing posts with label blank. Show all posts

Saturday, June 16, 2012

Excel Bubble Sort - Arranging Many Cells in Many Columns


In a previous post, and to some extent in a later one, I worked on ways to sort Excel cells in which data started out in an irregular arrangement, like this:



My goal in that case was to get the data items arranged in the original (vertical) order in a single column, like this:



This time around, I had a somewhat different objective. It seemed likely to require me to continue past the outcome just shown, to return the data to their original columns, but without the empty spaces between them, like this:


The question for this post was, how would I do that?


As I reviewed the previous posts, it seemed that the key step was to use Excel's CELL function. In the example just shown, an adjacent table containing formulas like =CELL("address",A1) and =CELL("address",A2) would produce values like $A$1 and $A$2. I could make those formulas conditional. Then =IF(A3="","",CELL("address",A3)) would return a blank cell. One additional step: I could combine the cell's address and its contents, like this:


The formula for that was =IF(A1="","",CELL("address",A1)&"--"&A1).  Now I could set up a shadow table, matching the original one cell for cell, with the same number of rows and columns, and with each cell containing this kind of CELL formula.  

With that done, I could copy the parallel table to a word processor that would have the ability to remove line breaks.  (The find-and-replace symbol for a line break in Microsoft Word was usually ^p.)  The table I was working on had 100 columns and about 3,000 rows.  Each column had just 30 actual data items, so there were a total of exactly 3,000 (not 300,000) actual data items in that table; all the other cells were blank.  Word 2003 was not able to accommodate this table initially, so I pasted it into Notepad++ and saved it as a text file, and then opened that in Word.  After a series of find-and-replace operations (replacing double tabs (i.e., ^t^t) and so forth), I wound up with a single column of entries, 53 pages long.

I pasted that list back into a different Excel table, temporarily, for further operations.  I parsed the entries into separate columns, using FIND to divide each item into its address and its contents.  In the first cell shown in the example above, the address was $A$1 and the contents were 3.  Now I had the 30 items that had originally been in column A, the 30 items that had been in column B, and so forth, without any of those blank cells.  This resulting set of 3,000 items was  all still just in one long column, but I could sort them in column order; I could take another few steps and sort them in row order; or I could sort them by increasing data item value.

So at that point, I had achieved approximately what I had tried to do in at least one of the preceding posts.  Now there was the additional step of getting the 30 items pertaining to column A back into column A, leaving me with a table 100 columns wide but only 30 (not 3,000) rows deep.  To do this, I did go ahead and isolate out the column and row information into separate columns.  It was awkward to put the Excel column letters into proper order -- getting AA after Y, and so forth -- so I set up another column with numbers as substitute column indicators.  To do that, I did a unique data filter to get just a single representative from each column (e.g., AA, AB, ...), and then did a VLOOKUP to the appropriate number in a table built from that unique filter (e.g., Y = 1, Z = 2, AA = 3 ...).  This gave me a table which, after sorting, began like this:


I further modified this table by adding a Row # column after the existing Row column.  For this project, I didn't care what row the item came from in the original spreadsheet; I just cared that it was sorted in proper row order and that it would appear somewhere within rows 1-30 of my new table.  So the numbers in this new Row # column just ran from 1 to 30, matching the 30 items from a given column in the original spreadsheet (e.g., Y), and then they started over again at 1 and ran up to 30 for the next original column (e.g., Z), and so forth).  This was easy enough to arrange:  after setting up the first set of 1 to 30, the cells in all following rows could just refer to the value appearing 30 rows up.  So now I had set of 1, 2, 3 ... 30, appearing over and over again, all the way down my new Row # column.  I added a new NAddress column to express the combination of row and column: 


With that in place, I could do a lookup to complete the job.  This called for two tables.  The top left corners of those two tables looked like this:



Note the formulas shown for the top left data cell in each of these two tables.  The first table produced the thing that I would be looking for in my VLOOKUP; the second was the final data table.

I soon discovered that I should have included a VALUE formula in that final table's calculations; the resulting data were behaving like strings, not numbers, so I did have to do that additional transformation.  Otherwise, though, the data checked out OK, so this task was done.

Wednesday, March 21, 2012

BIOS Problem: Bootup to Blank Screen

I had a working computer.  Then I decided to fix it.  Now the screen was completely black.  The computer seemed to have booted up nonetheless -- the hard drive light was flashing now and then, suggesting that some program was playing with itself in what I hoped was a nondestructive fashion -- but I could not see anything onscreen.  The monitor was plugged in and turned on, but I guess we were no longer on speaking terms.

What I had tried to fix was a setting in the BIOS.  I was using a Gigabyte GA-MA785GM-US2H motherboard with an Award BIOS (v. 6.00PG).  On bootup, I hit DEL and went into the BIOS settings -- specifically, into Advanced BIOS Features > IGX Configuration > UMA Frame Buffer Size.  My objective was to dedicate some system RAM to video.  So I hit Enter and changed the IGX Configuration from Auto (the default) to 512MB and rebooted.  This gave me the aforementioned black screen, just as it had done for another poor soul.

So now the question was how to fix it.  I first tried to do it blindly.  I booted the machine and kept hitting DEL for a while, figuring that this would take me into the BIOS setup.  Then, following the sequence of steps that would have been required to change the IGX Configuration back to Auto on another machine, I went through a series of keystrokes (Down, Enter, etc.).  Those steps, done in the proper order, took me to the IGX Configuration part of the BIOS on that other machine.  But they didn't seem to work on the blacked-out machine.  When I hit the keys needed to save the settings and reboot, I found myself still looking at a black screen.

If the BIOS was fubared such as to produce a black screen immediately upon bootup, without ever showing a trace of life, then it wouldn't seem to matter whether I booted with a CD, USB drive, floppy, or hard drive.  The one exception, I figured, would be if I booted with some program designed to speak directly to the BIOS.  And for that, the candidate was presumably a BIOS flasher.

In other words, I saw an opportunity, here, to update my BIOS while fixing it.  For this solution, I went to the motherboard's BIOS upgrade download webpage.  Gigabyte had a program called Xpress Recovery2, but its purpose seemed to be to recover hard drive data, not to recover the BIOS.  They also had @BIOS, a live update utility, which would have been great if I could have booted Windows to run it.  The motherboard's manual seemed to be telling me that I needed, instead, to use its Q-Flash utility.  Q-Flash was said to be embedded in the motherboard's hardware, so I wouldn't need any particular drive to run it.  It said I could use Q-Flash to install a BIOS update that I would download on the other computer and save to a FAT32/16/12 USB flash drive.

But could I use Q-Flash if I couldn't even see it?  The way to fire up Q-Flash, according to the manual, was to hit the End key while the system was booting.  The blanked system was currently running, so I tried using WinKey-U-R to restart it, since I could see that those keystrokes were what it would have taken to reboot the other computer from Windows 7.  I gave that several minutes, since I had no idea what was running on that computer at this point.  I never got a beep, though, so I thought maybe it was waiting for me to Force Restart.  I hit the F key.  Nothing happened.  I tried Enter.  A brief hard drive flicker.  I gave it another minute and then just punched the reset button on the computer.  Then I kept hitting End for a while.  Perhaps I was now in Q-Flash.  No way of knowing:  the screen was still blank.

I thought of trying to trace my way through a BIOS flash blindly, as I had tried to trace through the reset of the IGX Configuration option.  Thinking of that gave me an obvious idea:  reset!  Maybe I could just take the steps needed to reset the entire BIOS back to its defaults.  I punched the computer's restart button again and then, after I got the reboot beep, I kept hitting Del, twice a second for about 15 seconds.  The keys I hit at this point (copied, again, from the sequence on another machine running a hopefully similar CMOS setup utility) were:  right-arrow (to take me to the option for Load Fail-Safe Defaults), Enter (to actually load those defaults), then Y to confirm, then F10 to save and exit.  That produced no results, so I hit Esc several times, in hopes of backing out to the main CMOS menu, and tried again:  Right, Enter, Y, F10.  This time I added another Enter for good measure.  And oh, my Christ, it worked.  I was able to read my screen again.  Fricking brilliant.  Amazing what you can do when you can't see a thing.

I went back into the BIOS, because of course I hadn't had enough of this, to take a look at how things were now.  The UMA Frame Buffer Size was back to Auto.  Funny, I didn't recall even seeing a UMA Frame Buffer option on the other computer.

It seemd obvious, now, that I should have just gone directly for the Fail-Safe option in the first place.  I reconfigured the BIOS as desired, saved, and rebooted.  Everything was fine.  I wasn't going to need to root around anymore in my Google search for solutions.  Although I did realize, a bit later, that I probably could have achieved the same thing, without working blindly -- resetting the BIOS (a/k/a clearing the CMOS) -- by either removing the quarter-sized battery from the motherboard for five minutes or shorting across the motherboard's "clear CMOS" jumper, which the manual would probably have helped me to find.

But no.  Not so fast.  On reboot, I was back to a black screen.  Why?  I hadn't even touched the IGX Configuration stuff this time around.  But, ah, false alarm.  Apparently the fail-safe options concealed the Power-On Self-Test (POST) information.  After a short panic, I had Windows onscreen.  I'd just have to take another look at the CMOS setup, next time I rebooted, to find the setting that would restore the POST display during bootup.  There may have been a way to do that with Gigabyte's Easy Tune utility, though if there was, it wasn't immediately obvious to me.

I decided to go ahead and deal with that now.  Unfortunately, when I rebooted and hit Del repeatedly, it just gave me a blank screen.  I hit Esc and then Enter, to exit the BIOS and reboot without saving any changes, but that didn't do anything.  I tried again, and then tried F10 and Enter.  After a blank screen, that got me back into Windows, at least.

Well.  Were the fail-safe defaults preventing me from getting into the CMOS setup?  It seemed that maybe I should go ahead and update the BIOS after all, or else open the computer and use one of those hardware BIOS-reset methods.  I ran Gigabyte's @BIOS utility and selected the "Update BIOS from Gigabyte Server" option.  I had to approve a couple of choices, and then it ran.  In a half-minute or so, it had apparently downloaded the new version.  It said this:

The screen will freeze for a few seconds while updating the BIOS.
Do you want to update the BIOS?
I clicked OK.  After a moment, it said, "BIOS Update completed!  You must restart your system to take new changes."  I said, "Restart Later."  I didn't want to lose all the stuff I had open, so I hibernated the machine (Start > Shut Down > Hibernate) and then, after it died, I pushed the power button and started it back up.  That worked:  I could now see the POST screen.  I hit Del and went into the CMOS setup.  I had to reset the clock and make other adjustments.  Then I rebooted.  And yet, once again, I was not seeing the POST screen, though once again at least the computer did proceed on into Windows.  It seemed that maybe one of my changes was responsible for this, or else perhaps that the hibernation was fouling things up.

It was hard to tell what ultimately fixed this.  Something did.  When I returned to these notes a while later to wrap up this post, I was no longer having the problem.  Possibly the steps described here did solve it on reboot, though I think in that case I would have made note of it.  It seemed I would need to have the problem again in order to comment further on it.