Hi,
I'm trying to use the input from the user (Range or number that i can offset from a fixed cell).
The error returned is:
I Highlight the code where it goes wrong.
If i use Range("C16") it works
but if i use the variable (as range) afbnr i get the error.
What am i doing wrong here?
I'm trying to use the input from the user (Range or number that i can offset from a fixed cell).
The error returned is:
I Highlight the code where it goes wrong.
If i use Range("C16") it works
but if i use the variable (as range) afbnr i get the error.
What am i doing wrong here?
VBA Code:
Sub Uploadafbeelding1_C16()
Dim afbnr As Range
Set afbnr = Application.InputBox(prompt:="Selecteer cel voor afbeelding", Type:=8)
If afbnr Is Nothing Then Exit Sub
Dim profile As String
On Error GoTo 0
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Filters.Add "Picture Files", "*.bmp;*.jpg;*.gif;*.png"
.ButtonName = "Select"
.AllowMultiSelect = False
.Title = "Selecteer afbeelding"
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
Dim img As Shape
Dim nH
Dim nW
Dim nPix
Dim x
Set img = ActiveSheet.Shapes.AddPicture _
(Filename:=fd.SelectedItems(1), _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoCTrue, _
Left:=ActiveSheet.[B][COLOR=rgb(184, 49, 47)]afbnr[/COLOR][/B].Left + 2, _
Top:=ActiveSheet.Range("C16").Top + 2, _
Width:=-1, _
Height:=-1)
With img
.LockAspectRatio = msoTrue
' .Width = 38
.Height = 58
End With
With Selection
nH = img.Height + 4
' nW = img.Width + 4
Range("C16").RowHeight = nH
'Range("C16").Rowwidth = nH
End With
Else
MsgBox ("Geannuleerd.")
End If
End With
End Sub