KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 378
- Office Version
- 2016
- Platform
- Windows
Hi there are some who can get these 2 VBA codes running together. So when I affect a button I made, the VBA code must first copy the cells and paste them again. And then import the images.
Someone who can help. All help will be appreciated. Best regards Klaus W
Someone who can help. All help will be appreciated. Best regards Klaus W
VBA Code:
Sub Rektangelafrundedehjørner6_Klik()
'Copy the data
Sheets("Stamdata").Range("p9:p15").Copy
Worksheets("Billeter").Range("b2").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
Sub Rektangelafrundedehjørner1_Klik()
Dim pictname As String
Dim pastehere As Range
Dim pasterow As Long
Dim x As Long
Dim lastrow As Long
lastrow = Worksheets("Billeter").Range("B1").CurrentRegion.Rows.Count
x = 2
For x = 2 To lastrow
Set pastehere = Cells(x, 1)
pasterow = pastehere.Row
Cells(pasterow, 1).Select 'This is where picture will be inserted
pictname = Cells(x, 2) 'This is the picture name
If Len(Trim(pictname)) > 0 Then
ActiveSheet.Pictures.Insert("C:\Users\k-wit\Documents\Rejseafregning\" & pictname & ".png").Select 'Path to where pictures are stored
End If
With Selection
.Left = Cells(pasterow, 2).Left + (Cells(pasterow, 3).Width - .Width / 1)
.Top = Cells(pasterow, 2).Top + (Cells(pasterow, 1).Height - .Height / 1.1)
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 370#
.ShapeRange.Width = 470#
.ShapeRange.Rotation = 0#
End With
Next
End Sub
Last edited: