Excel Vba Prog
Excel Vba Prog
Legal Notice
This book does not offer advice, but merely provides information. The
author offers no advice whether medical, financial, legal, or otherwise, nor
does the author encourage any person to pursue any specific course of
action discussed in this book. This book is not a substitute for professional
advice. The reader accepts complete and sole responsibility for the manner
in which this book and its contents are used. The publisher and the author
will not be held liable for any damages caused.
Excel VBA
Ultimate Excel VBA Programming Step By Step
Guide to Go from Beginner to Expert
By: William Ironside
Contents
Introduction to Excel VBA
What Is VBA?
The Difference Between VBA and A Macro
The Structure of A VBA Code
The VBA Module Outline
VBA Procedures and Routines
Sub procedures
Function procedures
The Meaning of Statements
Declaration statements
Executable statements
Assignment statements
Objects
Classes
The Purpose of Collections
The Relationship Between Different Objects
Properties
Methods
Variables and Arrays
Conditions
Loops
Getting Used to the Developer Toolbar
Understanding the VBA Development Environment
Check out your first recorded macro
Understanding Excel Dot Notation
Conditional Logic
VBA Examples and Techniques
Copy and Paste
Adding Buttons to Help You Stay Organized
The Most Popular Excel Functions
Frequent Troubleshooting
Conclusion
Introduction to Excel VBA
If you’re reading this, you probably have a basic understanding of Excel
macros already. The very useful Excel tool which helps you to complete
repetitive tasks much faster. It is a precious tool to learn, and something that
will definitely be useful to you and your work for a long time to come in the
future.
Although basic macros are very useful, there is so much more tat can be
done in Excel to make your work easier, more efficient, and less stressful.
When you learn how to create shortcuts that make your job easier, you have
a much higher level of concentration and ability to truly focus on a task
instead of becoming frustrated with mundane tasks.
However, if you want to reach a level of professionalism where you can
truly use the full power of Excel, you will need to become a master of
VBA. It is much more versatile than simply recording a macro, and it
allows you to have almost endless possibilities with anything that Excel is
naturally able to do. But it does require some knowledge of programming in
order to do it properly. However, this is not a complex level of
programming, so there is no need to worry if you are not a programming
expert. You will get the hang of it in no time with a little bit of practice.
This helpful guide will teach everything that you need to know in order to
use and make the most of VBA. It is organized in logical chapters, so the
best way to get started is to follow each chapter in order so that you don’t
miss any points that connect to other points. Everything makes logical sense
in VBA. So, if you can take a moment to make sure that you have the
proper ground work ready, you can then continue your VBA programming
journey and design VBA programming actions on your own.
What Is VBA?
VBA is short for Visual Basic for Applications. It’s a type of programming
language which was developed by Microsoft. Almost everything that is part
of Microsoft Office is in one way or another based on the possibilities of
VBA. This is one of many programming languages that exist in the world,
but it is really not nearly as difficult to learn as some of the other
programming languages out there.
If you have no previous experience working with a programming language,
the first thing that you should keep in mind is that a programming language
is based on the same principles as any other language on our planet. In
order for the programming language to make sense, certain things must be
included in each command, and they have to be in the correct order. The
same way that you need to align words in your own language in a particular
order if they are to create a thought that makes sense.
However, you will not use programming languages to talk to another
person, you will use them to talk to software. More precisely, you will be
sending the software specific instructions which the software will then
complete for you. But only if you have created the right commands. If there
are any errors in the programming that you wish to send to a software, it
will not complete the task the way you want it to.
In this instance, we will be using VBA to talk to Excel and to make sure
that we can create an environment in Excel that works best for us and helps
us to be as efficient as humanly possible. You will start your journey in
learning VBA by understanding its structure. When you can understand the
structure, you can then easily use each element to create your own journey
through Excel through VBA.
The Difference Between VBA and A Macro
Before we move further, we must make a quick distinction between macros
and VBA, because they are not the same thing. Although VBA is a
programming language, a macro is not. A macro is simply a sequence of
instructions which tells Excel which simple, repetitive tasks it should do in
your stead to make your work life easier. On the other hand, VBA is an
actual programming language and far more complex than a macro. And
although this might sound intimidating to beginners, the possibilities of
VBA are above and beyond to what a simple macro can do. Although VBA
and macros may seem similar because they both allow the automation of
tasks in Excel, they are certainly not the same thing.
The Structure of A VBA Code
The best way to start your journey of learning how to use VBA is to learn
the structure of its code. When you understand the work environment that
VBA works in, you can easily maneuver your way around it and set it up so
that it works best for you.
The VBA code is a combination of programming commands which is
viewable in the VBA code view browser. No matter how long the code is,
the entire code, from the first command to the last one, will be visible in
this single window.
Each code has its own separate window, and different aspects of the code
are marked with different colors. The code is written in what is known as
the VBE (Visual Basic Editor), which you will always use when you want
to construct a new code for Excel.
The VBA Module Outline
Modules are locations in Excel where the VBA codes are stored. Each code
has its own module, and they are organized based on date and topic. You
can also organize the modules any way you like and give them names so
that you can distinguish them better. You can add and remove modules as
you like, and the better you organize them overall, the easier it will be for
you to reach the codes that you need to use at a particular moment.
VBA Procedures and Routines
A procedure is literally the part of the program that performs a task. It is the
part of the Excel software which understand the code and then follows each
step of the code that had been written down. All statements of a code
together fall under the complex understanding of a procedure. You
personally don’t have to worry about procedures because they are triggered
automatically when you decide to use a code. However, it is always good to
understand the terminology in case you see an error for one of your codes
and wonder what went wrong. Under the umbrella of procedures in general
are other types of procedures which all work together simultaneously in
order to smoothly execute a code.
Sub procedures
These are small procedures which are part of the overall general procedure
of a code. Sub procedures usually control the start and end points of a code,
and they also help to trigger other smaller aspects of an entire code, such as
styling fonts or moving from one cell to another. You will use sub
procedures when you construct your code, so you will always need to make
sure that each sub procedure that is started also has a clear end point
somewhere in the code. Sub procedures in the code are marked with the
color blue, so you will easily be able to spot them as you are constructing
your code.
Function procedures
These procedures are the ones that make complex calculations, especially
those that have to do with mathematics. When they are done with their
calculation, the function procedures will return a value into a designated
cell of your choice. You will not be coding the function procedures from
scratch. Instead, you will insert a particular mathematical formula that you
need to use somewhere in your code, and Excel will do the rest
automatically. For example, you will not write “add the following numbers”
into the code that you are making. Instead, you will type “SUM” and then
select the cells that needed to be added up together.
The Meaning of Statements
A statement is a very important part of the code because it is the trigger for
all instructions. This is the part that notifies Excel that a particular task is
about to happen and that action will be required from the software in order
to complete this process properly. Similarly to procedures, there are two
different types of statements that you need to understand.
Declaration statements
These statements determine variable and constants. Simply put, declaration
statements declare the next section of the code that is coming up. For
example, the words that you use to write the code for a sub procedure is
declaration statements because it declares that a type of procedure is about
to get started. You will not be able to change the basic structure of a
declaration statement, nor would you want to, but it is good to understand
the terminology so that you can make your way around the VBA coding
window easier.
Executable statements
These statements are more concerned with actions and how they will apply
to your overall code. They tell Excel that an action is about to take place
and they name the kind of action that will happen. In coding, even though
you can get super creative about what you want to do, you still cannot
invent a new coding language. You can only use the terminology of coding
that has been developed so far.
Assignment statements
These are very specific executable statements which further assign a value,
a variable, or a constant to parts of your code. They make the code much
easier for Excel to understand, even though it may seem that they are a little
more work for you. Although these are another sub category of statements,
they are crucial for the code to work. Your code must make each section of
its coding understandable and clear for the software to work properly.
Remember, if you make mistakes in your code, you may not even realize
that you have made a mistake until it’s too late. This is especially true if you
are working with numbers and a lot of data, because you will not be able to
realize immediately that the number you are getting is incorrect. This can
cause a lot of trouble in the future, so it is important that you understand
that each part of the code must be properly completed in order for the whole
thing to work correctly.
Objects
When Excel performs a particular action, this is called an object. An object
is therefore constructed from the previous elements that we mentioned, such
as statements and procedures. Altogether, when they are executed, they
complete an entire action that is called an object. The VBA systems
basically moves by manipulating different objects one after another in order
to complete a complete task that you would like to assign to it. This is why
it was important to cover the initial terminology first so that you can
understand that each element is part of a whole. And the whole needs to be
developed and checked properly in order for the object to be able to work
properly in the end. Other examples of objects include cell ranges,
workbooks, cell fonts, and worksheets. The most popular types of objects
are ActiveCell (the cell that has currently been selected in the Excel
workbook) and Selection objects, which in this case is the fact that you are
focusing strictly on cells for this particular task.
Objects are further defined by the classes that they have been described and
classified by.
Classes
Classes are features of the code which help to define an object. Their
special role is to define the events, properties, procedures, and variables of
an object. You will probably not be working with classes in the beginning
of your VBA journey, but they will become an important part of your
coding as you become more and more proficient in VBA. Classes are like
the blueprint of an object, which help to further define it and make sure that
the object is always working properly. The reason why you will not need to
work with them in the beginning is because coding classes is a lot more
complex than the coding that you will be used to as a beginner. Try to avoid
them for as long as you are still in the process of learning the codes and
only start playing with them when you are confident that you know enough
about every other aspect of coding in Excel. The reason why is because
even the slightest mistakes in classes will cause the entire code to fail. But
don’t worry, you will definitely get to that point someday.
The Purpose of Collections
Collections in VBA always refer to collections of objects. The feature of
collections in Excel groups similar objects together into one group. Not
only does this help you as a user make your way through the many codes
that will eventually pile up, but it will also help Excel to find the right
object at the right time. You are free to organize and rename the collections
however you like, just make sure that you always make the collections clear
and to the point so that when you want to use them you know exactly which
collection is referring to which part of the Excel use for you.
The Relationship Between Different Objects
Objects are always related to each other in one way or another. Usually,
objects are related to each other due to what is called ‘containment’,
because one object can contain one or more objects within it. Objects are
contained within each other in collections, which help to categorize them
and also help Excel to use the correct object when a particular task is
triggered. But objects are not randomly contained within one another.
Instead, they follow very strict rules of hierarchy, which is further related to
classes. This hierarchy is important for determining which object is
triggered at which point and in which chronological order. Don’t let any of
this confuse you because it all really does make perfect sense once you
become more and more familiar with Excel.
Properties
An object uses properties to help to be defined on a more detailed level. The
properties of a single object don’t have to be permanent for the entire
duration of the object’s life. you can change and alter different properties
related to a particular object without having to code the entire task all over
again from scratch. If you are just starting your journey in Excel, it is
probably best not to interfere with properties too much until you are more
comfortable with your coding skills. But do make a note of this ability
because it will greatly help you when you start organizing all of the codes
that you will be developing in the future.
Methods
Methods are also part of the structure of objects. You may start to think now
that there are too many things going on for you to remember, but it will all
become very easy to understand and to connect together into a whole once
you start working in Excel. The way objects work is that something need to
be done to the object before it is officially activated. This thing that is done
to the object is known as the method. Every method is a different action that
is performed by Excel with the object.
Variables and Arrays
Variables are the equivalent of a storage location. They are assigned names,
either automatic names or names that they have been given by the user, and
they are stored in the computer’s memory. Usually, you can determine
which part of the computer’s memory they will be stored in. Creating a
variable in Excel goes through the process known as declaring, which
means that you assign a name to the variable and also what the
characteristics of this particular variable will be. You will also need to
allocate the appropriate storage space, and you will also need to remember
the location of the storage space so that you can access it again later when
needed. You can declare variables at different levels of a module, depending
on where you want the variable to be activated. You can also use keywords
to define different variables so that you can groups variables together based
on the topic that they are referring to. This is great for making sure that you
can find a variable with ease whenever you need to use it.
If you are only using a single item in a variable, this is known as a scalar
variable. However, if you are adding a group of items to a variable then you
are dealing with arrays. Arrays share the same type of data among them,
and there is a logical relationship between each item. This is another
example where you can see how logical and organized Excel really is, and
although it may seem complex now, it will all become very clear when you
start using all of these elements to create your own codes and tasks.
Conditions
Conditions in VBA only have two purposes. To either determine something
as true, or determine it as false. Depending on which one out of the two will
be determined, Excel will decide whether something needs to be done or
not. For example, if it is TRUE that a cell is colored red, the number inside
it should be the following number in the series. Therefore, if the cell is not
red, (i.e. FALSE) Excel will not do anything in this situation and will not
add the next number in the series. If something is true, something else will
happen. Or, if something is false, something else with either happen or not
happen.
This is one of the most useful features of Excel coding and it is also the
easiest one to grasp because there are only two possible choices for you to
choose from and both of them are logical.
Loops
Loops are another way for VBA to understand that if a particular statement
is present or absent, then something else will happen as a result. However,
the difference between loops and other elements of coding which determine
whether something will happen or not, is that the function of a loop is
specified once, and then it just continues to happen for as long as it is
needed. Loops are very useful when it comes to creating tasks that will
most likely be repeated many times again in the future. These are the kinds
of tasks that you need to do when you have a huge list of data and the way
to handle it is to do one or two things over and over again. This really
makes the whole process much easier, and it also saves you a lot of time
which you can then use to do something more useful for your job.
Getting Used to the Developer Toolbar
Now that you have completed a basic level of knowledge of VBA tools and
terminology, let’s start by opening the developer toolbar before we go any
further. There will be other terminology coming up, however, let’s switch to
a few more active activities so that you don’t always have to just be looking
at words without doing anything.
The easiest way to start the process is to make sure that you have the
Developer ribbon attached to the top of Excel. This will ensure that you
have always access the developer bar when you either need to create a new
code, or when you need to use a code that you have already created in the
past. To do this, click on the round Office button, the click on Options, and
then click on “Top options for working with Excel”. You will see a box
called “Show Developer tab in the Ribbon”. Click on this option to turn it
on. Now, go to Excel’s File menu and click on Options. Click on Customize
Ribbon, and then check the box that is named “Developer”. You will now
see many new tools appear in the Excel Developer Ribbon above. It may
take you a bit of time to familiarize yourself with all of them, but once you
do, you will be on a whole new journey to making the most of Excel’s
macros and the VBA system.
Understanding the VBA Development
Environment
The VBA environment is the one part of Excel that you will obviously need
to get used to the most if you are to make the most of VBA’s capabilities.
Luckily, Excel has made this environment very intuitive, allowing you to
easily reach the areas that you need to work on at that moment. The way to
open the VBA environment is to simply to click on the VBA button in the
ribbon that you made previously. You will see a window pop open with
everything you need in order to use VBA and all of its functions.
At first, it may look like it has too many buttons for you to grab a hold of,
but you will soon realize that most of the buttons that you are seeing are
actually buttons that you have used in your life before. If you have ever
worked in Microsoft Office on a document that included text, you will have
easily seen almost all of these buttons before and you will already know
how to use them all.
The VBA environment is divided into the area on the left which is known
as the project, and the area on the right which is where you will create and
review all of the codes that you have made. Now, let’s make your first quick
little code to get you started!
In the white area on the right, type this code:
Sub Helloeveryone()
MsgBox "Hello everyone!"
End Sub
You will see the code appear in the coding window, and you will also notice
that some of the words are in a different color, as we mentioned before.
Now let’s see how it looks like when you actually run the code. To run the
code, check out the toolbar above. You will see a green triangle which looks
like a “play” button. Click on the green triangle and your code will pop out
in front of you in a new little window, and it will say Hello everyone!
Check out your first recorded macro
Now let’s watch your very first Excel macro being recorded. This is a great
way for you to understand the ins and out of how Excel actually works. And
when you see how a macro is recorded with your own eyes, it will be a lot
simpler and more logical for you to create your own codes in the future.
Everything will make a lo more sense when you are able to see how Excel
understands and prepares the codes for macros, so that they can be used
again in the future.
Most professional developers will tell you, though, that Excel tends to make
things a lot more complicated than they should be when it records things on
its own. This is a software after all, so it relies on pre-programmed codes to
help it as much as possible. When you create these codes on your own, they
will not need to be as complex and as long as Excel tends to make them.
Start by opening the Excel coding sheet side by side to your Excel
worksheet. Now, let’s make Excel record something simple such as aligning
numbers in a column. To do this, in the column A, write a list of numbers
one after the other. For example, you can write the numbers 1 to 10. Then,
click on the Record Macro button in your developer toolbar at the very top.
You will see a new dialogue box open. In this dialogue box, you will need
to give your macro a name, and from the list of selections under “Store
macro in”, make sure that you choose Personal Macro Workbook. This way,
you will ensure that all of your created macros are safely stored in the same
place and that you will not have any security issues in the future. Click OK
when you’re done. Excel is now recording your macro.
Now, go back to the cells that you wish to align in the worksheet. Select all
the numbers 1 to 10, click on the alignment that you wish to make, and
when the numbers are properly aligned, go up to the toolbar and click “Stop
Recording”. In the coding window, you will now see a new item appear,
usually with the title “Personal”, in which your new recorded macro has
been placed. You can click on this and then expand it to see how the macro
code looks.
You have now completed the recording and saving of your very first macro!
If you are someone who is just starting out on this journey, you can
continue to create and record macros this way for as long as you like. It will
be especially useful if you already know the steps that you take more
frequently when you are working in a particular Excel worksheet.
Understanding Excel Dot Notation
Dot notation is an important part of Excel codes. You will often see it when
you are developing or recording macros so it is important that you know
what it means and how you can use dot notation to help you create macros
faster and in a way that is more efficient.
Everything to the left of the dot is an object, and everything to the right of a
dot is what you want to do with an object. For example, if you see a code
that says ActiveCell.Font.Name = “Ariel” it means that you want to change
the font of the current active cell to the Ariel font.
You can use dot notation for any type of code in Excel, and the better you
get to know it the more complex and efficient your codes will be. Because
there are practically no limits to the kinds of codes you can create in VBA,
as long as you understand the language of the coding, you never have to
worry about creating a code that will end up being incorrect.
Conditional Logic
Conditional logic is a very versatile way to develop your codes in Excel.
The conditional logic feature is what will help you differentiate between
different information and different cells in your worksheet, which is the
thing that you will usually be working with most of the time. Conditional
logic is usually very difficult at first glance for people who do not have
previous coding experience, but it makes perfect sense and only takes a few
tries before you become a professional at it. There are a few different types
of logic that Excel recognizes, and we will now go through each one of
them so that you can easily choose which one suits you best for completing
a particular task in Excel.
If Statements
As the name suggests, IF something happens, then something else should
happen as a result. However, if the thing does not happen, then nothing
should change. Similar to the conditionals that you use in your own
language to distinguish between conditions, the programming language uses
the same logic to complete the same process – except in this case you are
talking to a piece of software. This is the simplest of the logical codes, and
it is certainly the first one that you should start with if you have not created
a macro before. Even though there are other conditional logics for you to
choose from, you can actually use the IF function to create any kind of
conditional logic. Of course, for the more complex codes of conditional
logic your IF code will look a lot longer than the conditional logic that you
could have used to speed things up.
Else
This is a part of the code that you can add within an IF statement to give it
more depth and complexity for what you want it to do. You will add this
part of the code after the initial request for the IF code. For example, if you
want to create a code that will tell Excel “If a number is 5 leave it, if the
number is not 5 (else) clear the cell”. This is another versatile code that you
can use however suits you best.
VBA Examples and Techniques
Now that you have a lot more knowledge about VBA and how to code your
own macros, we can now move on to giving you a better helping hand when
it comes to working in Excel. You will soon notice that when you start
coding macros, you can use elements from one macro and then tweak them
to serve you in another one. You don’t always need to code everything from
scratch in order to make your life easier.
In fact, recycling codes from old macros is one of the fastest ways to get
your work done without feeling overwhelmed by the process. So, in order
to help get you started, we will now list a number of the most useful and
most frequently used macros in Excel. You can start by using these codes as
they are, and then when you reach a more advanced level, you can tweak
the codes to make them more personal for you. When you feel like you
have reached a true level of professionalism, you can then code your own
macros entirely from scratch.
Check out the most useful and most common codes that you will need for
VBA:
Copy and Paste
This is easily the most used feature of any text software or any other
software that uses text. And although it is one of the most useful features as
well, sadly, it can easily become annoying when it needs to be done for a
long period of time. When you have to do something over and over again it
becomes tedious and annoying, and it will likely prevent you from
continuing your work without getting annoyed. This is why this is one of
the most useful macros to have saved in your Excel work. And, there are
different things that you will be looking to copy and paste in your work, so
here are all the options of copy/cut and paste that are possible in Excel.
Copy/Cut and Paste single cell
As its name suggests, this code copied info from one cell to another. You
don’t need to know any kind of coding in order to use this as a macro, but
you do need to make sure that you change the cell names to the ones that
you will be using in your work.
Sub Paste_OneCell()
'Copy and Paste Single Cell
Range("B1").Copy Range("D1")
'Cut and Paste Single Cell
Range("B1").Cut Range("D1")
Application.CutCopyMode = False
End Sub
Copying a selection
Sometimes, you will want to copy an entire selection of what you are
working on. Make sure that you change the cell range and name before
using this code.
sub CopySelection()
'Paste to a Defined Range
selection.copy range("b1")
'Offset Paste (offsets 2 cells down and 1 to the right
selection.copy
selection.offset(2,1).paste
end sub
Save As in VBA
As you work on and organize your Excel files, there will often come a time
when you wish to save your work, or part of your work, as a new file.
Instead of going through the entire process of saving your current work as a
new file, this useful code helps you to complete the entire process with a
single click:
workbook object .SaveAs(FileName, FileFormat, Password,
WriteResPassword, _
ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution,
_
AddToMru,TextCodepage, TextVisualLayout, Local)
You may want to skip adding passwords to your work for the time being,
because if you happen to get locked out of your work, it’s going to be quite
the hassle to try and get back in. although passwords are certainly great for
security, skip them until you are confident enough in your coding skills
before you go back to using them again.
Highlighting duplicates
Many people use Excel to organize hundreds or thousands of cells of
information. For example, some people use it to organize the names and
email addresses of people that they could potentially contact for a project.
Excel doesn’t automatically tell you if you have a duplicate cell or not,
because it allows you to continue with your work as quietly as possible.
However, you really wouldn’t want to contact someone who have already
contacted and seem annoying. This super handy code will find the
duplicates for you so that you can delete them before anything
uncomfortable happens.
Sub Highlight_Duplicates(Values As Range)
Dim Cell
For Each Cell In Values
If WorksheetFunction.CountIf(Values, Cell.Value) > 1 Then
Cell.Interior.ColorIndex = 6
End If
Next Cell
End Sub
The above is very useful when you want to only focus on a single color.
However, if you want to be super organized, you can give each topic of
content in your worksheet a specific color as you go through it. There are a
total of 56 different colors in Excel that you can choose from. An even
more handy code is the one that calculates the sums for each color at the
same time. This saves you time so that you don’t have to use the above code
over and over again.
Private Sub CommandButton1_Click()
'Will look at each color and produce summary table of values
'on sheet 1 in cell A1 and downwards
Dim Current_Color_Number As Integer
Dim Color_Total As Double
For Current_Color_Number = 1 To 56
Color_Total = Color_By_Numbers(Sheets("Sheet2").Range("a11:aa64"),
Current_Color_Number)
Worksheets("Sheet1").Range("A1").Offset(Current_Color_Number, 0) =
Current_Color_Number
Worksheets("Sheet1").Range("A1").Offset(Current_Color_Number,
0).Interior.ColorIndex = Current_Color_Number
If Color_Total 0# Then
Worksheets("Sheet1").Range("a1").Offset(Current_Color_Number,
1).Value = Color_Total
End If
Next Current_Color_Number
End Sub
Create new worksheet and give it a name when you open Excel
This is the perfect code for people who use Excel all the time and who
always start their work day with a new worksheet. This code is a simple
way to make your life just that little bit easier first thing in the morning,
ensuring that you don’t start your work day having to organize new
worksheets. Instead, as soon as you login to the computer, you will already
be ready to go and start working.
Private Sub Workbook_Open()
Dim New_Sheet_Name As String
New_Sheet_Name = Format(Now(), "dd-mm-yy")
If Sheet_Exists(New_Sheet_Name) = False Then
With Workbook
Worksheets.Add().Name = New_Sheet_Name
End With
End If
Save
End Sub
Sheet_Exists = False
For Each Work_sheet In ThisWorkbook.Worksheets
If Work_sheet.Name = WorkSheet_Name Then
Sheet_Exists = True
End If
Next
End Function
With Application.FileSearch
.NewSearch
.LookIn = File_Path
.Filename = "*.*"
.SearchSubFolders = False
.Execute
No_Of_Files = .FoundFiles.Count
For kk25 = 1 To No_Of_Files
Worksheets("Sheet1").Cells(kk25 + 5, 15).Value = .FoundFiles(kk25)
Next kk25
End With
End Sub
Sub GoToAnotherCellInAnotherSheetInTheSameWorkbook()
ActiveSheet.Hyperlinks.Add Range("A1"), Address:="", SubAddress:="'"
& Sheet2.Name & "'!B2", TextToDisplay:="Click Here to Go to
Sheet2, cell B2 of the same workbook"
End Sub
End Sub
'================================
Sub TestForMergedCells()
AnyMerged = ActiveSheet.UsedRange.MergeCells
End Sub
'=====================================
This book does not offer advice, but merely provides information. The
author offers no advice whether medical, financial, legal, or otherwise, nor
does the author encourage any person to pursue any specific course of
action discussed in this book. This book is not a substitute for professional
advice. The reader accepts complete and sole responsibility for the manner
in which this book and its contents are used. The publisher and the author
will not be held liable for any damages caused.
Excel VBA
Ultimate Excel VBA Programming Step By Step
Guide to Go from Beginner to Expert
By: William Ironside