• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

What is the different between Dim vs Set?|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / What is the different between Dim vs Set?|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosWhat is the different between Dim v…
sp_PrintTopic sp_TopicIcon
What is the different between Dim vs Set?
Avatar
Guest
Guest
Guests
1
December 28, 2019 - 6:33 pm
sp_Permalink sp_Print

Hi,

I saw the below coding from youtube. Anyone can help me to understand what is the different between "Dim" & "Set"?

Are we able copy the table in editor format?

Thank you.

 

Sub CopyPicture()
Dim mypicture As PowerPoint.Application
Set mypicture = New PowerPoint.Application

mypicture.Visible = msoTrue

Dim mypicture_pres As PowerPoint.Presentation
Set mypicture_pres = mypicture.Presentations.Add

Dim mypicture_slide As PowerPoint.Slide
Set mypicture_slide = mypicture_pres.Slides.Add(1, ppLayoutBlank)

Dim mychart As ChartObject

Range("B2:G12").Select
Selection.Copy

mypicture_slide.Shapes.PasteSpecial ppPasteBitmap

End Sub

sp_AnswersTopicSeeAnswer See Answer
Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
December 30, 2019 - 4:08 pm
sp_Permalink sp_Print

Hi,

Dim is used for declaring the object name and type, "Set" is to assign a value to it.

Set is used for objects only, not for all variables, for example:

Dim Rw as Long

Rw=54

 

What you have in that file is not a table, it's a colored range of cells that looks like a table.

Instead of pasting as image, try this:

mypicture_slide.Shapes.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse

You can double click on it to edit.

Avatar
Guest
Guest
Guests
3
December 30, 2019 - 6:01 pm
sp_Permalink sp_Print

Thank you Catalin. With this editable coding, does it link to the original source file or mainly the table copy over to pptx?

I am not an expert in macro, still at learning stage. However, I am curious are we able to track how fast macro is running when we execute the coding/program? My manager always asked me to reduce my cycle time to process a report. I wonder how to show her the timing / speed when a macro run? Do you have any idea?

 Thank you.

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
4
December 31, 2019 - 2:56 pm
sp_Permalink sp_Print

As you can see, the line I sent has this: Link:=msoFalse
You can change it to true if you want to keep the link to original object.

At the beginning of your code:

Dim StartTime as double

StartTime=Now()

At the end of your code:

Msgbox "Elapsed time: " & Format((Now()-StartTime)/24/60/60,"hh:mm:ss")

sp_AnswersTopicAnswer
Answers Post
Avatar
Guest
Guest
Guests
5
December 31, 2019 - 5:29 pm
sp_Permalink sp_Print

Hi Catalin,

Very helpful coding. I have tried it but the result showed as Elapsed time : 00:00:00. Does this mean the time is very fast not even 1 second?

Thank you.

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 612
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
December 31, 2019 - 7:31 pm
sp_Permalink sp_Print

I think it should actually be:

MsgBox "Elapsed time: " & Format((Now() - StartTime), "hh:mm:ss")

Avatar
Guest
Guest
Guests
7
January 2, 2020 - 1:12 pm
sp_Permalink sp_Print

Thank you Velouria. It works well. 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Laurence Chapman, Ben Hughes, Alison West, Manjula Mangalmurti
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
yashal minahil
Oluwadamilola Ogun
Yannik H
dectator mang
Francis Drouillard
Orlando Inocente
Jovitha Clemence
Maloxat Axmatovna
Ricardo Freitas
Marko Meglic
Forum Stats:
Groups: 3
Forums: 24
Topics: 6201
Posts: 27185

 

Member Stats:
Guest Posters: 49
Members: 31861
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.