macro help - newbie

G

Greg Henderson

Hello

I have resisted learning Macro's - but I will have to give in and see
the better way. Excel Office X

Could someone help me on this issue and I can reverse engineer how you
did it to learn other ways ( is there a book that is recommended? )

I have three rows in a long report so manually doing it is getting
boring.
line sub line sub line description
AAA 1 Big Widgets
2 Blue Widgets
3 Red Widgets
Total

I need to get the data like this - so I can sort various ways
line sub line sub line description
AAA 1 Big Widgets
AAA 2 Blue Widgets
AAA 3 Red Widgets
AAA Total

The logic I think is need it this

For A=1 to end of file
if C3 is Blank - then next A
If A2 is NOT BLANK then next A
let A 2 copy data from A1
goto next line
next A

How do you set this up?

Thanks for help

Regards

Greg H

ps - see why I would starve as a programmer :)
 
B

Bill

I have assumed (shudder) several things from your question.
you have multiple sections of data, separated by at least
an empty space in the third column between the data sets.
The first row of each data set has an entry in column 1
and this is the entry you want copied.

My macro was written for Excel 2002 for Windows so I do
not know if the find last cell command is correct for
EXCEL Office X. if not, there should be an equivalent in
EXCEL X whihc you can find by Recording a macro while
using the appropriate comands to goto the last cell in the
Worksheet.

Try this macro

Sub macrofill()
' adds info to first column from the above cell when third
column has an entry and first ' 'column does not

' First find last row
Selection.SpecialCells(xlCellTypeLastCell).Select
rl = Selection.Row

' start "for statement"
' assumes row one is labels
For r = 2 to rl

' check third column
If cells(rl,3) = "" then next r
'checks first column
if cells(rl,1)= "" then cells(rl,1)=cells(rl-1,1)
next r
end sub
 
J

JE McGimpsey

Greg Henderson said:
Hello

I have resisted learning Macro's - but I will have to give in and see
the better way. Excel Office X

If I understand you correctly, you can do this without macros. Since
your example was sparse, I assume that your report reads something like
this:

AAA 1 Big Widgets
2 Blue Widgets
3 Red Widgets
Total
AAB 1 Big Widgets
2 Blue Widgets
3 Red Widgets
Total
AAC 1 Big Widgets
2 Blue Widgets
3 Red Widgets
Total

in that case, Select Column A and choose Edit/Goto. Click Special,
select the Blanks radio button and click OK.

Type the equals sign (=), then the up arrow (the formula bar will show

=A1

hold down the CTRL-key and type Return.

The data will now look like

AAA 1 Big Widgets
AAA 2 Blue Widgets
AAA 3 Red Widgets
AAA Total
AAB 1 Big Widgets
AAB 2 Blue Widgets
AAB 3 Red Widgets
AAB Total
AAC 1 Big Widgets
AAC 2 Blue Widgets
AAC 3 Red Widgets
AAC Total
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top