Lacampeona
New Member
- Joined
- Mar 31, 2024
- Messages
- 7
- Office Version
- 2016
- Platform
- Windows
Hello experts
I am new in writing my own procedures so yesterday and today I have some problems with excel.
I am lost in strings. I tried everything I dont know what I am doing wrong! Helpppp meee!!
I have a code written and saved under module in lets say Excel tblDsd.xlsm. That macro I convert in "Smile Face" in ribbon tab. When I am working with Excel tblSp.xlsm and I click the "Smiley face" to run my macro, everytime again and again the workbook A is also opening.
My question? why?
Where I should paste my procedure for macro for smiley face?
A) Modul
B) Worksheet
C) Workbook
Here is the code foy my "Smiley Face":
Thanks in advance experts
I am new in writing my own procedures so yesterday and today I have some problems with excel.
I am lost in strings. I tried everything I dont know what I am doing wrong! Helpppp meee!!
I have a code written and saved under module in lets say Excel tblDsd.xlsm. That macro I convert in "Smile Face" in ribbon tab. When I am working with Excel tblSp.xlsm and I click the "Smiley face" to run my macro, everytime again and again the workbook A is also opening.
My question? why?
Where I should paste my procedure for macro for smiley face?
A) Modul
B) Worksheet
C) Workbook
Here is the code foy my "Smiley Face":
Sub ImportDatafromotherworksheet()
Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Dim rngSourceRange As Range
Dim rngDestination As Range
Set wkbCrntWorkBook = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Set rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A1", Type:=8)
wkbCrntWorkBook.Activate
Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A1", Type:=8)
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
End Sub
Thanks in advance experts