Do Copy Paste on different Cell, when type "OK",Macro newbie, Help!

radian89

Board Regular
Joined
Nov 12, 2015
Messages
113
Hi All,

linkback : Do Copy Paste on different Cell, when type "OK",Macro newbie, Help!

I Have this problem. I want to when type OK, it'll copy and paste it as value based on its row. and select other cell
like this pic below.

so when i type OK :
- on D5, it'll copy F5:H5, and paste to J5:L5, and then select cell N5
- on D6, it'll copy F6:H6, and paste to J6:L6, and then select cell N6
.
.
.
and so on until D14.

right now i'm using this code below on worksheet change, but it's too long, and kinda evaluate from first - end every time run the code... someone help me?

i've also upload the file here http://s000.tinyupload.com/?file_id=34348770715604698398

thanks a lot for the help
warm regards,

Adrian

ff7955.jpg
[/IMG]



Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Range("D5").Value = "OK" Then
    Application.EnableEvents = False
    Range("F5:H5").Copy
    
    Sheets("Sheet1").Range("J5:L5").PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    
    Range("N5").Select
Else
        
End If


Application.EnableEvents = True


'-----------------------------------------------------------
If Range("D6").Value = "OK" Then
    Application.EnableEvents = False
    Range("F6:H6").Copy
    
    Sheets("Sheet1").Range("J6:L6").PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    
    Range("N6").Select
Else
        
End If


Application.EnableEvents = True


End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hello Radian,

The code that Davesexcel supplied does the job. If all you want is to add a line to select corresponding cells in Column N, then add the following line:-


Code:
Cells(Target.Row, "N").Select

just after this line:-

Code:
Range(Cells(Target.Row, "J"), Cells(Target.Row, "L")).Value = Range(Cells(Target.Row, "F"), Cells(Target.Row, "H")).Value

Cheerio,
vcoolio.
 
Upvote 0
Hello Radian,

The code that Davesexcel supplied does the job. If all you want is to add a line to select corresponding cells in Column N, then add the following line:-


Code:
Cells(Target.Row, "N").Select

just after this line:-

Code:
Range(Cells(Target.Row, "J"), Cells(Target.Row, "L")).Value = Range(Cells(Target.Row, "F"), Cells(Target.Row, "H")).Value

Cheerio,
vcoolio.

Hi vcoolio,
And it works... woohooo...

(y)
thanks a lot...
warm regards

Adrian
 
Upvote 0
Excellent Adrian! Glad that I was able to help out.

Cheers to Davesexcel also.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,217,404
Messages
6,136,416
Members
450,010
Latest member
Doritto305

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