VBA to write value in column 1 based on column 2 and column 3

dmadhup

Board Regular
Joined
Feb 21, 2018
Messages
146
Office Version
  1. 365
I have the following macro to write the value in column 1 based on the available value in column 2 and 3

Code:
Sub ColumnValue()
    Range("A18").Value = "=IF($B$18=0,0,1)"
    Range("A19").Resize(Cells(Rows.Count, "B").End(xlUp).Row - 18) = "=IF(C19=1,A18,IF(C19=0,A18+1,""""))"
End Sub

But I want to see the column1 value like this pattern

Col1 Col2 Col3
1 1 0
1 2 1
1 2 1
1 2 1
2 2 0
2 3 1
2 3 1
2 3 1
2 3 1
2 3 1
1 2 1
1 2 1
3 1 0
3 2 1
3 2 1
3 2 1
3 2 1
3 2 1
4 2 0
4 3 1
4 3 1
4 3 1
4 3 1
3 2 1
3 2 1
5 1 0
5 2 1
5 2 1
5 2 1
5 2 1
5 2 1
5 2 1
5 2 1
5 2 1
6 2 0
6 3 1
6 3 1
6 3 1
6 3 1
5 2 1
5 2 1
5 2 1
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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