Help with Macro Excel 2007

smyk

New Member
Joined
Jan 14, 2009
Messages
10
Hi All,
Would someone be able to help me with macro that will make my work life a lot easier. This is something that I do manually everyday.

1. For value FS, FD and FQ in col E copy value from col L to col F;

2. For value CS and CT in col E if there is value N in col G copy value from col L to col F, if there is value Y in col G and 0 in col H copy value from col L to col F,
if there is value Y in col G and more than 0 col H copy value from col K to col F;

3. For every PT in col E check value in col M if the value is more than 0 copy value from col K to col F if there is 0 or less in col M and less than 0 in col N copy value from J to col F if more than 0 in col N then do nothing.

Thanks in advance,
Lukasz
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Never mind, I got my answer if anyone is interested here's the code

Code:
Dim lastrow As Long, icell As Long
lastrow = Range("E" & Rows.Count).End(xlUp).Row
For icell = 1 To lastrow
    Select Case Range("E" & icell).Value
        Case Is = "FS"
            Range("F" & icell).Value = Range("L" & icell).Value
        Case Is = "FD"
            Range("F" & icell).Value = Range("L" & icell).Value
        Case Is = "FQ"
            Range("F" & icell).Value = Range("L" & icell).Value
        Case Is = "CS"
            If Range("G" & icell).Value = "N" Then
                Range("F" & icell).Value = Range("L" & icell).Value
               
            ElseIf Range("G" & icell).Value = "Y" And Range("H" & icell).Value = "0" Then
                Range("F" & icell).Value = Range("L" & icell).Value
            ElseIf Range("G" & icell).Value = "Y" And Range("H" & icell).Value >= 0 Then
                Range("F" & icell).Value = Range("K" & icell).Value
            End If
        Case Is = "CT"
            If Range("G" & icell).Value = "N" Then
                Range("F" & icell).Value = Range("L" & icell).Value
            ElseIf Range("G" & icell).Value = "Y" And Range("H" & icell).Value = "0" Then
                Range("F" & icell).Value = Range("L" & icell).Value
            ElseIf Range("G" & icell).Value = "Y" And Range("H" & icell).Value >= 0 Then
                Range("F" & icell).Value = Range("K" & icell).Value
            End If
        Case Is = "PT"
            If Range("M" & icell).Value > 0 Then
               Range("F" & icell).Value = Range("K" & icell).Value
            ElseIf Range("M" & icell).Value < 1 And Range("N" & icell).Value < 0 Then
                Range("F" & icell).Value = Range("J" & icell).Value
            End If
    End Select
Next icell
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

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