Use of If statement for a column

mprasannna

New Member
Joined
Jun 29, 2014
Messages
3
Hi All,
I have a database in which there are 3 columns named as Name , Category & New category.

Name Category New Category
George 5 1
Michel 4 1
Robert 4 7
Hunk 8 8

In the new category column, if any cell's value is <>1, then the same value require to be pasted in category column corresponding to the name. In this data mentioned above, only the category number of Robert will be changed from 4 to 7 .
Please help me with a VBA code to do this..

Thank you
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi All,
Correct data is given below


Name - Category - New Category
George - 5 - 1
Michel - 4 - 1
Robert - 4 - 7
Hunk - 8 - 1
 
Upvote 0
Try on a copy of your data. Assumes "New Category" is column C.

Rich (BB code):
Sub value2value()
    Dim c As Range

    For Each c In Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row)

        If c.Value <> 1 Then
            c.Offset(0, -1).Value = c.Value
        End If

    Next

End Sub

I am assuming there is no - in the cells
 
Upvote 0

Forum statistics

Threads
1,216,604
Messages
6,131,697
Members
449,666
Latest member
Tommy2Tables365

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