PC Review


Reply
Thread Tools Rate Thread

Copying a cell contents down to the next non-blank cell

 
 
Math
Guest
Posts: n/a
 
      21st Mar 2007
I have a database download that always comes in a frustrating format.
It's effectively outlined, eg. rather than having field names as
column headers and record going down, it has (using as simple an
example as I can describe) the record-ID in A2, Field "A" Name in B2,
Field "A" value in C2, then Field "B" Name in B3, Field "B" Value in
C3, etc. There can be any number of fields in the list (it only
downloads the fields with values), but only the one record-ID at the
top left. After the last field, there's a blank row before the next
record starts.

Anyway, ideally I'd like to macro this up to put the field names as
column headers and then one record per row, but currently that's way
above me.

For now, I'd like help with a simple macro that copies the record-ID
down into every row applicable to that record.

- From the active cell
- find the next non-blank cell (i'm guessing with a loop using
IsEmpty)
- define a range from the active cell down to the next non-blank cell-
minus 2 (because of the blank line)
- Autofill that range with the original activecell's value
- select the next nonblank cell and repeat

Any help would be appreciated.

(getting things back into the original format in order to upload is a
problem I don't even want to consider at the moment!)

Many thanks

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      21st Mar 2007
First, I'd get rid of those completely empty rows.

Can you pick out a column that always has data in it if the row is really used?

If yes, you can use something like:

with activesheet
on error resume next

..range("x1").entirecolumn.cells.specialcells(xlcelltypeblanks).entirerow.delete
on error goto 0
end with

Those empty rows will cause confusion in data|filter, data|subtotal, data
pivottable--so I'd toss them.

After that, I'd use some code at Debra Dalgleish's site to fill the empty cells
in the columns I needed:
http://contextures.com/xlDataEntry02.html


Math wrote:
>
> I have a database download that always comes in a frustrating format.
> It's effectively outlined, eg. rather than having field names as
> column headers and record going down, it has (using as simple an
> example as I can describe) the record-ID in A2, Field "A" Name in B2,
> Field "A" value in C2, then Field "B" Name in B3, Field "B" Value in
> C3, etc. There can be any number of fields in the list (it only
> downloads the fields with values), but only the one record-ID at the
> top left. After the last field, there's a blank row before the next
> record starts.
>
> Anyway, ideally I'd like to macro this up to put the field names as
> column headers and then one record per row, but currently that's way
> above me.
>
> For now, I'd like help with a simple macro that copies the record-ID
> down into every row applicable to that record.
>
> - From the active cell
> - find the next non-blank cell (i'm guessing with a loop using
> IsEmpty)
> - define a range from the active cell down to the next non-blank cell-
> minus 2 (because of the blank line)
> - Autofill that range with the original activecell's value
> - select the next nonblank cell and repeat
>
> Any help would be appreciated.
>
> (getting things back into the original format in order to upload is a
> problem I don't even want to consider at the moment!)
>
> Many thanks


--

Dave Peterson
 
Reply With Quote
 
Math
Guest
Posts: n/a
 
      21st Mar 2007
On 21 Mar, 12:50, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> First, I'd get rid of those completely empty rows.
>
> Can you pick out a column that always has data in it if the row is reallyused?
>
> If yes, you can use something like:
>
> with activesheet
> on error resume next
>
> .range("x1").entirecolumn.cells.specialcells(xlcelltypeblanks).entirerow.de*lete
> on error goto 0
> end with
>
> Those empty rows will cause confusion in data|filter, data|subtotal, data
> pivottable--so I'd toss them.
>
> After that, I'd use some code at Debra Dalgleish's site to fill the emptycells
> in the columns I needed:http://contextures.com/xlDataEntry02.html
>
>
>
>
>
> Math wrote:
>
> > I have a database download that always comes in a frustrating format.
> > It's effectively outlined, eg. rather than having field names as
> > column headers and record going down, it has (using as simple an
> > example as I can describe) the record-ID in A2, Field "A" Name in B2,
> > Field "A" value in C2, then Field "B" Name in B3, Field "B" Value in
> > C3, etc. There can be any number of fields in the list (it only
> > downloads the fields with values), but only the one record-ID at the
> > top left. After the last field, there's a blank row before the next
> > record starts.

>
> > Anyway, ideally I'd like to macro this up to put the field names as
> > column headers and then one record per row, but currently that's way
> > above me.

>
> > For now, I'd like help with a simple macro that copies the record-ID
> > down into every row applicable to that record.

>
> > - From the active cell
> > - find the next non-blank cell (i'm guessing with a loop using
> > IsEmpty)
> > - define a range from the active cell down to the next non-blank cell-
> > minus 2 (because of the blank line)
> > - Autofill that range with the original activecell's value
> > - select the next nonblank cell and repeat

Excellent - thankyou

>
> > Any help would be appreciated.

>
> > (getting things back into the original format in order to upload is a
> > problem I don't even want to consider at the moment!)

>
> > Many thanks

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying selected contents in one cell to another cell The Needy Microsoft Excel Worksheet Functions 5 15th Sep 2009 03:03 AM
Copying cell contents from many cells and pasting into one cell MDN Microsoft Excel Misc 7 10th Dec 2007 08:56 PM
Copying format to a new cell, w/o overwriting destination cell contents James C Microsoft Excel Misc 1 18th Oct 2005 08:02 PM
Copying cell contents to add to existing contents in another cell =?Utf-8?B?RGVhbiBTYXdhcw==?= Microsoft Excel Programming 3 2nd Apr 2004 09:00 PM
Copying cell contents from a referred cell that is in reference to a "find" cell ZX210 Microsoft Excel Misc 1 26th Dec 2003 06:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 AM.