Properties & Property Values (Exercise)
ฝัง
- เผยแพร่เมื่อ 10 ก.พ. 2025
- VBA Fundamentals: Video 9
Link to Exercise File: drive.google.c...
-------------------------TOPICS-----------------------
INTRODUCTION TO PROPERTIES
This video covers the general syntax of properties, and how to use some of the properties for objects we are already familiar with.
SYNTAX
Object.Property = Property Value
EXAMPLES OF PROPERTIES AND THEIR VALUES
• Range.Value = "Text"
• Worksheets.Name = "Text"
• Range.WrapText = True/False
• Range.Bold = True/False
• Range.NumberFormat = "Text"
• Range.Font.Underline = Integer
RETURNING DATA about PROPERTY VALUES using IMMEDIATE WINDOW
?Object.Property
EXERCISE
Create a macro that:
1. In cell A1, enter the text, “This Week's Sales at Contoso"
2. In cell A1, bold the font
3. In cells B4:B8, program the number format so it matches the client’s example
4. In cells A3:B3, program the underline so that it matches the client’s example
Seriously. Best. Teacher. Ever. Can you do tutorials on all the things?
Lol for my next course: we will be learning how to wire an electrical socket, followed by a session on shearing sheep. I may need your help for certain topics though Swingkeke, how are your plant husbandry skills?
@@fosiebear Done and done. My plant husbandry skills are slowly increasing due to COVID. Is soil husbandry a thing? I could definitely help with that. And if you're gaga for shearing sheep, then Lambtown Fest in Dixon, CA is for you. From personal experience, it's amazing.
@@swinginkeke LMAO, I'm stoked! We should coin soil husbandry, are you talking compost? I'm, for real, learning how to garden from home and this is my next milestone. If you got skills, PLEASE SHARE
@@fosiebear Two words: worm tea. Check out the principles of permaculture. It's garden-changing!
What is the exact use of "Immediate window" ? please suggest
Hi Pooja, another AWESOME question!! The immediate window allows you to test run small statements to see how they will work. It displays immediate results, right now, without needing to run the whole macro. It's great if you need to test a small portion of your code to see if you wrote it out right, or to see if your calculation is returning the right results. We are going to use this a lot more often coming up. But wanna see something cool before then? Try typing these into the immediate window (without the preceding dash) and pressing enter:
- MsgBox "Hi Pooja!"
- ?Range("A1").NumberFormat
- Worksheets(1).Name = "I'm a code ninja"
You can actually type any Object.Method or Object.Property into the immediate window and you get immediate results!