VBA# if statement# copy to next cell

Rasika21

New Member
Joined
Feb 5, 2014
Messages
18
Hello,

I would like to know how to run if condition statement for specific column.
Below mentioned is data and criteria I want to apply. Basically I want to update Points as per Membership package and give deadline to use points. I can use if statement for first transaction through VBA coding but I dont know how to do it for whole data.
Databse
[TABLE="width: 636"]
<tbody>[TR]
[TD]Bill Date[/TD]
[TD]Guestname[/TD]
[TD]Membership Name[/TD]
[TD]Points[/TD]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[/TR]
[TR]
[TD]18-08-17[/TD]
[TD]sadhvi s[/TD]
[TD]You First(++) Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]22-08-17[/TD]
[TD]Avtar Kaur[/TD]
[TD]You First(++) Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]23-08-17[/TD]
[TD]MANOJ .[/TD]
[TD]You First Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]20-08-17[/TD]
[TD]Sheersha Arun[/TD]
[TD]You First Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]22-07-17[/TD]
[TD]Deepali .[/TD]
[TD]You First Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]20-08-17[/TD]
[TD]sushmita .[/TD]
[TD]You First Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]21-08-17[/TD]
[TD]Pankaj .[/TD]
[TD]You First Membership[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Criteria

[TABLE="width: 443"]
<tbody>[TR]
[TD]Membership Name[/TD]
[TD]Points[/TD]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[/TR]
[TR]
[TD]You First(++) Membership[/TD]
[TD]400[/TD]
[TD]`=Billdate+7[/TD]
[TD]`=Billdate+60[/TD]
[/TR]
[TR]
[TD]You First(+) Membership[/TD]
[TD]350[/TD]
[TD]`=Billdate+7[/TD]
[TD]`=Billdate+60[/TD]
[/TR]
[TR]
[TD]You First Membership[/TD]
[TD]300[/TD]
[TD]`=Billdate+7[/TD]
[TD]`=Billdate+60[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Assuming that your data is in columns A to F, make sure that columns A, E and F are formatted as 'Date'. Try the following macro:
Sub
Code:
copyData()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim MN As Range
    For Each MN In Range("C2:C" & LastRow)
        Select Case MN.Value
            Case "You First(++) Membership"
                MN.Offset(0, 1) = "400"
                MN.Offset(0, 2) = MN.Offset(0, -2) + 7
                MN.Offset(0, 3) = MN.Offset(0, -2) + 60
            Case "You First(+) Membership"
                MN.Offset(0, 1) = "300"
                MN.Offset(0, 2) = MN.Offset(0, -2) + 7
                MN.Offset(0, 3) = MN.Offset(0, -2) + 60
            Case "You First Membership"
                MN.Offset(0, 1) = "300"
                MN.Offset(0, 2) = MN.Offset(0, -2) + 7
                MN.Offset(0, 3) = MN.Offset(0, -2) + 60
        End Select
    Next MN
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
My apologies. I meant you are "very welcome." I typed it on my cell phone and sometimes the autocorrect is not your friend!! :)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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