Macro to copy data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,595
Office Version
  1. 2021
Platform
  1. Windows
I have numbers in Col B followed by a full stop eg 1. 20. etc


I have tried to write code to copy the value in Col K that corresponds with 30. (same row) in Col B to Col K that corresponds with 25. in Col B same row


For eg the value in col K for 30. is K40 and the value is 108,965 and this must be copied as a value using paste special values in Col k in the same row as 25.

I get paste special class failed when running my macro


See my code below

it would be appreciated if someone could amend my code


Code:
 Sub Compute_Opening_inventory()

Dim lRow As Long, I As Long
lRow = Cells(Rows.Count, 11).End(xlUp).Row
For I = 1 To lRow
If Left(Cells(I, 1), 3) = "30." Then
   Cells(I, 11).Copy
End If
If Left(Cells(I, 1), 3) = "25." Then
    Cells(I, 11).PasteSpecial xlValues
   Application.CutCopyMode = False
    
End If
Next

End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
can you post a sample....what you have provided is confusing...at least to me anyway !!
 
Upvote 0
Thanks for the reply Michael



Book1
BCDEFGHIJKLM
125.Finished goods987,145
2
3
427.
528.
629.
730.Finished goods920,250
Sheet1



in this example, I want to copy K7 which is in the same row as 30. in Col B to K1, which in same row as 25. in Col B
 
Upvote 0
Hi Michael


Have you had a chance to look at the sample data I posted ?
 
Upvote 0
No, not really.....but on quick inspection, I'm assuming you mean Col L no Col K ???
AND
the value in "30." should overwrite the value in "25." ??
 
Upvote 0
Thanks for the reply


My apologies

You are 100% correct. It should be Col L and the value in "30." should overwrite the value in "25."
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
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