VBA code to move picture from on sheets to another sheet

Status
Not open for further replies.

KlausW

Active Member
Joined
Sep 9, 2020
Messages
458
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone

Anyone who can help, I use this VBA code to move picture from on sheets to another sheet.

Normally the pictures are in a row with the pictures in odd rows from A3 to L3 and A5 to L5 etc., and the employee numbers in the even rows A4 to L4 and A6 to L6. In the formula from A4 to L12. But now I want to take the pictures from B2 to C50. In column B are the pictures and in column C are the employee numbers they must refer to.

Anyone who can help?
Any help will be appreciated

Best Regards
Klaus W

VBA Code:
Sub Find()

Dim A, B, c, d As Range ' a = området på "Billeder 1.deling med navne på foto, b = område i "Billeder" med navne på billeder, c = de enkelte celler i a, d = de enkelte celler i b

ActiveSheet.Pictures.Delete ' de gamle billeder slettes

Set A = Range("a4:d4,a8:d8,a12:d12,a16:d16,a20:d20") ' a defineres

Set B = Worksheets("Billeder").Range("a4:L12") ' b defineres

For Each c In A

For Each d In B

If c = d And c <> "" Then ' der testes om de enkelte celler i a findes i b

d.Offset(-1, 0).Copy Destination:=c.Offset(-1, 0) ' hvis de findes, kopieres cellen ovenover i "Billeder" til cellen ovenover i "Billeder 1.deling"

End If

Next

Next

End Sub
 

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
Status
Not open for further replies.

Forum statistics

Threads
1,224,297
Messages
6,177,748
Members
452,798
Latest member
mlance617

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