VBA ro copy 2 cells if condition met

Kimpnc

New Member
Joined
Aug 17, 2015
Messages
13
I have the following code which works well but i now need to copy J & K if the condition is met

I have tried a couple of ways but cant get it to work so use same module but for J it would be much quicker if i could do them both together as there are often about 4-500,000 lines of data but on other occasions only 2000 lines.


Sub Addonx()
Linez = InputBox("How many LINES to process" & vbCr & "figure From Message Box")
For i = 1 To Linez
With Sheets("Dept Rept")

If .Range("D" & i).Value = "17354" Then _
.Range("K" & i).Value = "=R[-1]C"
End With
Next i
End Sub

Thanks for the help
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
but i now need to copy J & K if the condition is met
Copy them where?

It may be helpful if you can show us what your data actually looks like, and what you want the final result to look like.
You cannot upload files to this site. But there are tools you can use to post screen images. They are listed in Section B of this link here: http://www.mrexcel.com/forum/board-a...forum-use.html.
Also, there is a Test Here forum on this board that you can use to test out these tools to make sure they are working correctly before using them in your question.
 
Upvote 0
Copy them where?

It may be helpful if you can show us what your data actually looks like, and what you want the final result to look like.
You cannot upload files to this site. But there are tools you can use to post screen images. They are listed in Section B of this link here: http://www.mrexcel.com/forum/board-a...forum-use.html.
Also, there is a Test Here forum on this board that you can use to test out these tools to make sure they are working correctly before using them in your question.


Coudnt work out how to post the screen shot but worked out what i was looking for was

.Range("J" & i,"K" & i).Value = "=R[-1]C"#
tried everything but the comma between the cell refs.
Thanksanyway will have a look at posting screenshots for future thanks
 
Upvote 0

Forum statistics

Threads
1,223,635
Messages
6,173,481
Members
452,516
Latest member
archcalx

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