ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   6 cell copy macro (https://www.excelbanter.com/excel-programming/315230-6-cell-copy-macro.html)

Duncan_J

6 cell copy macro
 
I have six cells and only one of those cells is colored and has data...
Example
F G H I J K Y
1 blank blank data blank blank blank Copy cell that's not blank here
2 blank data blank blank blank blank Copy cell that's not blank here
3 blank blank blank blank blank data Copy cell that's not blank here
ect.
Is thier anyway to do this and to keep the cell color as well as the data?
Thanks,
DJ

crispbd[_4_]

6 cell copy macro
 

This is very similar to using the if statement as a worksheet functio
except for the color aspect. From your post it looks as though yo
would like to copy the cell (and its interior fill color) that contain
data to the adjacent column. A little For-Next loop macro would do th
trick, here's an example:

Sub BringData
'define the range to consider in the loop
' here we choose the first cell for the first three rows:
Dim Counter as Integer

For Counter = 1 to 3

If Cells(Counter,1).value < "" then
Cells(Counter,2).Value = Cells(Counter,1).Value

Cells(Counter,2).Interior.ColorIndex=Cells(Counter ,1).Interior.ColorIndex
Else
Cells(Counter,2).Interior.ColorIndex=2
End If

Next Counter

:

--
crispb
-----------------------------------------------------------------------
crispbd's Profile: http://www.excelforum.com/member.php...fo&userid=1088
View this thread: http://www.excelforum.com/showthread.php?threadid=27366


Duncan_J

6 cell copy macro
 
Thanks crispbd
Not going to work as it copies what's in cell A to B
I need something that will take the data and cell color to coulmn M
let's say row 1, column a b c d e f are all blank except c... I need c
copied to coulmn M.. next row, row 2, a,b,c,d,e,f are all blank except b.. I
need b copied to coulmn M along with it's color... In other words I just want
what ever data is in a-f coulmn and thier will only be one cell with data and
colored on each row ..
thanks for the help,
dj

"crispbd" wrote:


This is very similar to using the if statement as a worksheet function
except for the color aspect. From your post it looks as though you
would like to copy the cell (and its interior fill color) that contains
data to the adjacent column. A little For-Next loop macro would do the
trick, here's an example:

Sub BringData
'define the range to consider in the loop
' here we choose the first cell for the first three rows:
Dim Counter as Integer

For Counter = 1 to 3

If Cells(Counter,1).value < "" then
Cells(Counter,2).Value = Cells(Counter,1).Value

Cells(Counter,2).Interior.ColorIndex=Cells(Counter ,1).Interior.ColorIndex
Else
Cells(Counter,2).Interior.ColorIndex=2
End If

Next Counter

:)


--
crispbd
------------------------------------------------------------------------
crispbd's Profile: http://www.excelforum.com/member.php...o&userid=10880
View this thread: http://www.excelforum.com/showthread...hreadid=273665




All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com