VBA to Cut/Paste Values Based on Formatting

MIexcelNovice

New Member
Joined
Dec 17, 2014
Messages
15
Hi Everyone,

To be honest I'm not even sure if this is something that can be done with VBA, but since I consider myself a beginner when it comes to VBA code I figured this would be the place to ask.

So, I have a worksheet full of data that has dollar amounts in column B and names in Column I. Some of the names in column I are formatted with different colors and some have no color. I was wondering if there is a way to identify the names that are colored in column I and if they are colored, I need the corresponding dollar amounts cut from column B and pasted into the same row in column K.

Once again, I don't even know if this is a possibility, so any information would be greatly appreciated.
 
Try:
Code:
Sub CopyCell()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rName As Range
    For Each rName In Range("I2:I" & LastRow)
        If rName.Interior.ColorIndex <> 2 And Cells(rName.Row, "F") <> "" Then
            Cells(rName.Row, "F").Cut Cells(rName.Row, "K")
        End If
    Next rName
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Not sure what is happening. That code worked perfectly on the dummy worksheet, but when I tried it on another worksheet with the exact same format (just has different cells colored in the I column), it went back to moving all of the values from column F to column K. I think I should be able to work it out from here, I'm just not sure why it is doing this
 
Upvote 0
If you post a link to the other worksheet, I can have a look.
 
Upvote 0
That's where the problem lies. I know of no way to make it work if the cell fill is applied using conditional formatting.
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,291
Members
449,498
Latest member
Lee_ray

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top