MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 4th, 2004, 10:12 PM   #1
finaddict
 
Join Date: Mar 2004
Location: Daphne, AL
Posts: 33
Default

I just copied and pasted the code into the white box after right clicking the sheet tab and veiwing the code. It didn't do anything. But I'm pretty sure I didn't do something right.

Thanks,
Steve
__________________
I started out with nothing......I still have most of it!
finaddict is offline   Reply With Quote
Old Apr 4th, 2004, 10:17 PM   #2
HOTPEPPER
MrExcel MVP
 
HOTPEPPER's Avatar
 
Join Date: Mar 2004
Location: Oregon
Posts: 12,298
Default Re: Is this possible?

With your worksheet open, press ALT-F11, this will open the VBA Editor.

Select View...Project Explorer

On the project explorer Right click on the
Microsoft Excel Objects Folder for the current sheet.
Select Insert...Module

Just paste the code to this new module and close the explorer (ALT-Q)

Press ALT-F8 to bring up the macro window
Since copycolor is the name of this macro, select copycolor and hit Run.

When you save the worksheet, this code will be saved with it.
HOTPEPPER is offline   Reply With Quote
Old Apr 4th, 2004, 11:23 PM   #3
finaddict
 
Join Date: Mar 2004
Location: Daphne, AL
Posts: 33
Default

Still didn't work. Do I paste the code in sheet1 or sheet2?

Thanks,
Steve
__________________
I started out with nothing......I still have most of it!
finaddict is offline   Reply With Quote
Old Apr 5th, 2004, 03:00 AM   #4
finaddict
 
Join Date: Mar 2004
Location: Daphne, AL
Posts: 33
Default Re: Is this possible?

Hey Hot Pepper. I finally got it to work. Thanks for your help and patience.

Thanks,
Steve
__________________
I started out with nothing......I still have most of it!
finaddict is offline   Reply With Quote
Old Apr 5th, 2004, 03:12 AM   #5
finaddict
 
Join Date: Mar 2004
Location: Daphne, AL
Posts: 33
Default Re: Is this possible?

Well, I thought I did. If I change the numbers in sheet1 then it don't work.

Thanks,
Steve
__________________
I started out with nothing......I still have most of it!
finaddict is offline   Reply With Quote
Old Apr 5th, 2004, 06:29 AM   #6
HOTPEPPER
MrExcel MVP
 
HOTPEPPER's Avatar
 
Join Date: Mar 2004
Location: Oregon
Posts: 12,298
Default Re: Is this possible?

Are you re-running the macro after you change the numbers?

Hit Alt-F8 again, select the copycolor macro and hit RUN
HOTPEPPER is offline   Reply With Quote
Old Apr 5th, 2004, 02:09 PM   #7
finaddict
 
Join Date: Mar 2004
Location: Daphne, AL
Posts: 33
Default

Ok. I did have to hit alt-F8 and it did work. The problem I have now with it is that if there is a break in numbers it will not list the numbers after the break. For example: sheet1 column A has cells 1,2,3,5,9,12....which have a colored number in them. On sheet2 in cell A1 it will only list 1,2,3 and no other numbers. And if the column doesn't start in the first cell it doesn't list any numbers that are after that in other cells.

Thanks,
Steve
__________________
I started out with nothing......I still have most of it!
finaddict is offline   Reply With Quote
Old Apr 5th, 2004, 03:25 PM   #8
HOTPEPPER
MrExcel MVP
 
HOTPEPPER's Avatar
 
Join Date: Mar 2004
Location: Oregon
Posts: 12,298
Default Re: Is this possible?

I assume when you say there is a break in the numbers in the first column, you mean there is an empty cell between them, because the macro doesn't care what numbers are in them.
The macro is currently looking for the first blank cell it comes across in the columns to determine when it is finished, I will take a look at it later to see if I can come up with a better solution.
HOTPEPPER is offline   Reply With Quote
Old Apr 5th, 2004, 08:46 PM   #9
HOTPEPPER
MrExcel MVP
 
HOTPEPPER's Avatar
 
Join Date: Mar 2004
Location: Oregon
Posts: 12,298
Default Re: Is this possible?

OK, replace the old copycolor macro with this one. Please let me know how it goes:

Sub copycolor()
Dim combine As String
Dim colorarray(65536) As Long
Dim valuearray(65536) As String
w = 1
r = 0

Worksheets("Sheet2").Activate
Worksheets("Sheet2").Range("A1:IV65536") = ""

For x = 1 To 256

Worksheets("Sheet1").Activate
y = 1
Myrange = Worksheets("Sheet1").Columns(x)
q = Application.WorksheetFunction.Sum(Myrange)
While r <> q
d = Str$(Cells(y, x))
If d <> " 0" Then
c = c + 1
valuearray(c) = Str$(Cells(y, x))
colorarray(c) = Cells(y, x).Font.Color
combine = combine + valuearray(c) + ", "
End If
r = r + Cells(y, x)
y = y + 1
Wend

If combine = "" And r = q Then Exit Sub
combine = Left(combine, Len(combine) - 2)

e = 1
y = c
Worksheets("Sheet2").Activate
With Worksheets("Sheet2").Cells(w, 1)
.Value = combine
For u = 1 To y
z = Len(valuearray(u)) + 2
.Characters(e, z).Font.Color = colorarray(u)
e = e + z
Next u
End With
w = w + 1
combine = ""
r = 0
q = 0
c = 0
Next x
End Sub
HOTPEPPER is offline   Reply With Quote
Old Apr 5th, 2004, 09:03 PM   #10
finaddict
 
Join Date: Mar 2004
Location: Daphne, AL
Posts: 33
Default Re: Is this possible?

Like a FREAKIN' charm!!!!!!!!!!!! Worked beautifully!!!!!!!!! Man! How can I ever repay you? Can't thank you enough!
__________________
I started out with nothing......I still have most of it!
finaddict is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT +1. The time now is 04:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.