Help Needed to make this macro faster

Sathya89

New Member
Joined
Jun 6, 2012
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Happy day

Below is the data of my work and codes which I wrote with the help of google search. Data size will be variable.

I used numeric number "1" at the end of the workable range at the column c to identify the last row. I will enter values at the 8th row.

I used the match function and tricked by changing the intersect value to "0" and non-intersect value to "a" to make my code runnable.

Codes follows like this
Step 1:
Format in each row of column C to be copied to respective rows of given specified range.
Step 2 :
Check the each cell value in the given range is matching with any of the value in respective range of same row values at the right
Step 3:
If intersect(if cell value match with the value in the respective range of rows),respective cell to be formatted with respective column format and color from the top.

for example:
in row 10th --Values from the right most table say 1 , 8 is intersecting at G10,I10,M10,P10,S10,W10.The format from respective column at the 8th row will be copied to the respective intersecting cell.


My codes are running fine with very small range of 15 rows and 15 columns but taking too much when the specified range increased to 100 rows and 100 columns. For even more rows and columns, its taking very very too much time. So I need help to modify my codes to run faster or alternative codes are welcomed. I hope that i made clear of my requirement. Help would be appreciated.

Codes are below

Sub Latitude()
Dim FirstAddress As String
Dim Rng As Range
Dim i As Long
Dim ColumnNumber As Long
Dim ColumnLetter, ColumnLetter2 As String

Call longitude


'Get Last column from right and last row from bottom
Lastcolumn = ActiveSheet.Range("XFD8").End(xlToLeft).Column
ColumnLetter = Split(Cells(8, Lastcolumn).Address, "$")(1)

lastrow = ActiveSheet.Range("C1000000").End(xlUp).Row - 1

'Find the value using match
Range("E10:" & ColumnLetter & lastrow).ClearContents
Range("E10:" & ColumnLetter & lastrow).NumberFormat = ";;;" ' INVISIBLE
Range("E10:" & ColumnLetter & lastrow).FormulaR1C1 = "=IFERROR(MATCH(R8C," & "RC" & Lastcolumn + 3 & ":RC" & Lastcolumn + 19 & ",0)*0,""a"")"

'Copy and paste the formula values
Range("E10:" & ColumnLetter & lastrow).Select
Range("E10:" & ColumnLetter & lastrow).Copy
Range("E10:" & ColumnLetter & lastrow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

'Checking the values by looping and copy and pasting the formats from the top.
For i = 5 To Lastcolumn
ColumnLetter2 = Split(Cells(8, i).Address, "$")(1)
Range(ColumnLetter2 & 6).Select
Selection.Copy
Range(ColumnLetter2 & 10 & ":" & ColumnLetter2 & lastrow).Select

'On error move to next cell
On Error GoTo nextnext:
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeConstants, 1).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

nextnext:
Next i

Lastcolumn = ActiveSheet.Range("XFD8").End(xlToLeft).Column
Range("E10:" & ColumnLetter & lastrow).NumberFormat = ";;;" ' INVISIBLE
Application.ScreenUpdating = True
End Sub

Sub longitude()
Dim lastrow As Long
Dim ColumnLetter As String
Dim Lastcolumn As Long


Application.ScreenUpdating = False
'Find the last row using value
lastrow = ActiveSheet.Range("C1000000").End(xlUp).Row


Lastcolumn = ActiveSheet.Range("XFD8").End(xlToLeft).Column
ColumnLetter = Split(Cells(8, Lastcolumn).Address, "$")(1)
Range("E10:" & ColumnLetter & lastrow).Clear

For i = 10 To lastrow - 1
ActiveSheet.Range("C" & i).Copy (ActiveSheet.Range("E" & i & ":" & ColumnLetter & i))
Next i

End Sub



codes for formatting.xlsm
CDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAP
6Colors12345678910111213141516
7
8No34158367825892893412
9
1018
1129
1238
1339
1448
1549
162358
17669
181238
199
2078
2169
2258
2349
241238
2545679
261
Drawing




thanks in advance
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
And I need reverse of this code i.e selecting and formatting the non-intersecting cells. I don't where to edit this code.

Here’s one way to do it.
1. Put 0 in in all cell in helper column
d.Value = 0 'put 0 in all cell in helper column

2. Delete 0 in vc where the cell intersect
If va(1, k) = vb(i, j) Then vc(i, k) = "" 'delete value in vc

VBA Code:
Sub a1173102b()
'https://www.mrexcel.com/board/threads/help-needed-to-make-this-macro-faster.1173102/
Dim c As Range, d As Range
Dim i As Long, j As Long, n As Long
Dim k As Long, rc As Long
Dim va, vb, vc, t

t = Timer
Application.ScreenUpdating = False
n = Range("C" & Rows.Count).End(xlUp).Row - 1
rc = Cells(8, Columns.Count).End(xlToLeft).Column

Set c = Range(Cells(10, "E"), Cells(n, rc)) 'E10:X25
Set d = c.Offset(, rc * 2 + 100) 'temporary helper column, change to suit

d.Value = 0 'put 0 in all cell in helper column

c.Clear
'copy format C to E10:X25 format
Range(Cells(10, "C"), Cells(n, "C")).Copy
c.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'copy format to temporary helper column
Range(Cells(6, "E"), Cells(6, rc)).Copy
d.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'populating array
va = Range(Cells(8, "E"), Cells(8, rc)) 'row 8: range E8:X8
vb = c.Offset(, c.Columns.Count + 2)    'range AA10:AP25, assuming 2 columns separate the 2 areas (i.e E10:X25 & AA10:AP25)
vc = d                                  'temporary helper column, all 0

For i = 1 To UBound(vb, 1)

    For j = 1 To UBound(vb, 2)
    
        If vb(i, j) <> "" Then
        
            For k = 1 To UBound(va, 2)
                
                If va(1, k) = vb(i, j) Then vc(i, k) = "" 'delete value in vc
            
            Next
        
        End If
    
    Next

Next

'populate result to temporary helper column
d = vc
d.Copy
'paste format from helper column to E10:X25 with SkipBlanks:=True
c.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=True, Transpose:=False

Application.CutCopyMode = False
d.Clear 'clear temporary helper column

Application.ScreenUpdating = True

Debug.Print "It's done in: " & Timer - t & " seconds"

End Sub

Here's the helper columns look like if you run the code up to this line:
'populate result to temporary helper column
d = vc


Book1
EWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQ
8
9
1000000000000000
11000000000000000
120000000000000
13000000000000000
1400000000000000
150000000000000000
1600000000
1700000000000000000
1800000000
19000000000000000000
20000000000000000
2100000000000000000
2200000000000000
230000000000000000
2400000000
25000000000000
26
27
Sheet2
 
Upvote 0
Solution
Please suggest books and video reference for learning vba.
If you want to learn VBA have a look this list of resources kindly compiled by @hiker95
What Is VBA?
VBA is an acronym for Visual Basic for Applications. VBA should not be confused with VB, which is standard Visual Basic. Visual Basic for Applications is a programming feature designed by Microsoft for use with their Microsoft Office

MrExcel's Products: Books, CDs, Podcasts Discuss topics related to Holy Macro! Products: Learn Excel from MrExcel, VBA and Macros for Microsoft Excel,Holy Macro! It's 2500 VBA Examples CD, Guerilla Data Analysis Using Microsoft Excel and Excel Knowledge Base CD and the MrExcel Podcasts.
MrExcel's Products: Books, CDs, Podcasts

There are over 1800 Excel videos/tutorials here:
http://www.youtube.com/user/ExcelIsFun

Getting Started with VBA.
DataPig Technologies

If you are serious about learning VBA try
http://www.add-ins.com/vbhelp.htm

Excel Tutorials and Tips - VBA - macros - training
MrExcel.com | Excel Resources | Excel Seminars | Excel Products

MrExcel's Excel Tutorial Listing
MrExcel.com | Excel Resources | Excel Seminars | Excel Products

Excel VBA MACRO Kick-start Course for absolute beginner

Free VBA Course
Free VBA Training Course

Excel 2007 VBA materials to learn here:
VBA for Excel 2007 tutorial-VBA programming?

The macro recorder actually is your friend but look here:
Beyond Excel's recorder

Introduction to Variables, Constants and Data Types
http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx

Here's a good primer on the scope of variables.
Understanding Scope

Using Variables in Excel VBA Macro Code
Excel VBA Variables. Using Variables in Excel VBA Macro Code

See David McRitchie's site if you just started with VBA
Getting Started with Macros and User Defined Functions

What is a VBA Module and How is a VBA Module Used?
What is a VBA Module and How is a VBA Module Used?

Events And Event Procedures In VBA
Events In Excel VBA

Here is a good introductory tutorial using a VBA Class:
Classes In VBA

There's a chapter on classes in VBA Developer's Handbook which is also good.
http://www.amazon.com/VBA-Developers.../dp/0782129781

Ron's Excel Tips
Excel for Windows Tips

Ron de Bruin's Mail from Excel and make/mail PDF files (Windows)
Mail from Excel and make/mail PDF files (Windows)

How do I create and use a PERSONAL file for my VBA code
How do I create and use a PERSONAL file for my VBA code

Anthony's Excel VBA Page - Excel Application - Excel Consultant - Excel Consulting (see 3 tutorials in Excel VBA Basic Tutorial Series)

BET: Microsoft Excel Visual Basic

Debugging VBA
Debugging VBA

Debug Excel VBA Macro Code
Debug Excel VBA Macro Code

TechBookReport - Debugging Excel VBA Code
TechBookReport - Debugging Excel VBA Code

Here are some general links on performance improvement:
https://www.soa.org/News-and-Publica...s42-roper.aspx
Optimize Slow VBA Code. Speed Up Efficient VBA Code/Macros
Excel VBA Performance Coding Best Practices - Office Blogs
https://msdn.microsoft.com/en-us/library/aa730921.aspx

Start at the beginning...

Creating An XLA Add-In For Excel, Writing User Defined Functions In VBA
Creating An XLA Add In

Build an Excel Add-In
VBA Tips: Build an Excel Add-In

Creating custom functions
http://office.microsoft.com/en-us/ex...117011033.aspx

Writing Your First VBA Function in Excel
http://www.exceltip.com/st/Writing_Y...Excel/631.html

VBA for Excel (Macros)
Excel Macros (VBA) Tutorial

Excel Macros Tutorial
Excel Macros (VBA) Tutorial

Excel Macros & Programming
EXCEL Macros Tutorial

VBA Lesson 11: VBA Code General Tips and General Vocabulary
http://www.excel-vba.com/vba-code-2-1-tips.htm

Excel VBA -- Adding Code to a Workbook
http://www.contextures.com/xlvba01.html

Beyond Excel's recorder

Helpful as a simple concise reference for the basics, and, using the macro recorder is endlessly powerful.
http://www.techonthenet.com/excel/cells/index.php

Learn to debug:
Debugging VBA

How To: Assign a Macro to a Button or Shape
How To: Assign a Macro to a Button or Shape - Peltier Tech Blog

User Form Creation
http://www.contextures.com/xlUserForm01.html

Build a UserForm for Excel
http://www.fontstuff.com/ebooks/free/fsuserforms.pdf

When To Use a UserForm & What to Use a UserForm For
When to use Userform & What To Use Them For. Excel Training VBA 2 lesson 2

UserForms in Excel VBA - UserForm Basics; Add Controls dynamically at run-time using the Add Method; UserForm Controls (A Snapshot)

Excel VBA how to Personalise the Ribbon
excel vba how to personalise the ribbon - Bing video

Excel Tutorials / Video Tutorials - Functions
http://www.contextures.com/xlFunctions02.html

How to insert Buttons, radio buttons and check boxes in Excel
How to insert Buttons, radio buttons and check boxes in Excel - Bing video

INDEX MATCH - Excel Index Function and Excel Match Function
http://www.contextures.com/xlFunctions03.html

Multi or two way vlook up and index match tutorial
http://www.get-digital-help.com/

Excel Data Validation
http://www.contextures.com/xlDataVal08.html#Larger
http://www.contextures.com/excel-dat...ation-add.html

Excel -- Data Validation -- Create Dependent Lists
http://www.contextures.com/xlDataVal02.html

Create dependent drop down lists containing unique distinct values in excel | Get Digital Help - Microsoft Excel resource

Your Quick Reference to Microsoft Excel Solutions
XL-CENTRAL.COM : For your Microsoft Excel Solutions

New! Excel Recorded Webinars
DataPig Technologies

MS Excel: VBA Functions - Listed by Category
MS Excel: ALL Formulas/Functions - Listed by Category

Fuzzy Matching - new version plus explanation
Fuzzy Matching - new version plus explanation

Programming The VBA Editor - Created by Chip Pearson at Pearson Software Consulting LLC
This page describes how to write code that modifies or reads other VBA code.
Programming In The VBA Editor

VBA and Macros for Microsoft Excel, by Bill Jelen "Mr.Excel" and Tracy Syrstad

Excel Hacks 100 Industrial-Strength Tips & Tools, by David & Traina Hawley

VBA and Macros for Microsoft Excel 2007, by Bill Jelen "Mr.Excel" and Tracy Syrstad

John Walkenbach's power programming with Excel books.

Excel 2010 Power Programming with VBA, Mr. Spreadsheet's Bookshelf

by Stephen/ Bovey, Rob/ Green, John Bullen (Paperback - Feb 11, 2005)
Professional Excel Development

by Rob Bovey, Stephen Bullen, John Green, and Robert Rosenberg (Paperback - Sep 26, 2001)
Excel 2002 VBA: Programmers Reference

Professional Excel Development by Rob Bovey, Dennis Wallentin, Stephen Bullen, & John Green

DonkeyOte: My Recommended Reading, Volatility
Volatile Excel Functions -Decision Models

A list of Reference Books
AJP Excel Information

Sumproduct
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

Arrays
VBA Array Basics
VBA Arrays
Excel: Introduction to Array Formulas - Xtreme Visual Basic Talk
Excel VBA Lesson 21: Array in Excel VBA
The Complete Guide to Using Arrays in Excel VBA - Excel Macro Mastery

Array Dimensions in Visual Basic - Working with Dimensions (code and graphics)
http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx

Visual Basic Array Tutorial written by Adam Wehmann
Visual Basic Arrays Tutorial

Shortcut Keys in Excel 2000 through 2007

Pivot Intro
Using Pivot Tables in Microsoft Excel - Peltier Tech Blog
Office 2010 Class #36: Excel PivotTables Pivot Tables 15 examples (Data Analysis) - YouTube
http://www.youtube.com/watch?v=qMGILHiLqr0
Getting Started with Pivot Tables
http://www.contextures.com/xlPivot01.html#Start
Overview of PivotTable and PivotChart reports
http://office.microsoft.com/en-gb/ex...010342752.aspx
Build a Pivot Table in Excel VBA
Build a Pivot Table in Excel VBA : Microsoft Excel

Excel 2013 PowerPivot Basics #01: Introduction To PowerPivot for Excel 2013 - YouTube

Conditional Formatting
http://office.microsoft.com/en-001/e...102809768.aspx

Email from XL - VBA
Mail from Excel example pages

Outlook VBA
Writing VBA code for Microsoft Outlook

Mail a message to each person in a range
Mail a message to each person in a range

Excel Function Dictionary by Peter Noneley
http://www.xlfdic.com/
http://www.hoffits.com/

Function Translations
Excel function name translations - Dictionary Chart Front Page

Dynamic Named Ranges
http://www.contextures.com/xlNames01.html

How to create Excel Dashboards
http://www.contextures.com/excel-dashboards.html
Excel Dashboards - Templates, Tutorials, Downloads and Examples | Chandoo.org - Learn Microsoft Excel Online
Excel Dashboards - Templates, Tutorials, Downloads and Examples | Chandoo.org - Learn Microsoft Excel Online
Free Microsoft Excel Dashboard Widgets to Download
Gauge

Excel Dashboard / Scorecard Ebook
http://www.qimacros.com/excel-dashboard-scorecard.html

Mike Alexander from Data Pig Technologies
http://www.amazon.com/Excel-2007-Das...5564958&sr=1-1

Templates
CPearson.com Topic Index
http://www.contextures.com/excel-tem...lf-scores.html
Free Microsoft Excel Template Links & Search Engine

Financial Model Template
https://www.youtube.com/results?sear...finance&page=1

Microsoft Excel Cascading Listboxes Tutorial
http://www.youtube.com/watch?v=YAMvLJRwZdI

Date & Time stamping:
McGimpsey & Associates : Excel : Time and date stamps

Get Formula / Formats thru custom functions:
Show FORMULA or FORMAT of another cell

A nice informative MS article "Improving Performance in Excel 2007"
http://msdn.microsoft.com/en-us/library/aa730921.aspx

Progress Meters
Progress meters
http://www.xcelfiles.com/ProgressBar.html

How to convert text to numbers in Excel
http://support.microsoft.com/kb/291047

How to parse data from the web - Brett Fret has a video in YouTube
http://www.youtube.com/watch?v=6H7tBL97orE

Excel VBA MAC shortcuts
Mac Shortcuts for Excel

Macintosh Keyboard Shortcuts to use in Microsoft Excel
http://office.microsoft.com/en-us/ma...102927337.aspx

http://office.microsoft.com/en-us/ex...010073848.aspx

Excel VLOOKUP Multiple Sheets • My Online Training Hub

Wise Owl Tutorials
https://www.youtube.com/playlist?lis...3akx_gFMnpxTN5

http://msdn.microsoft.com/en-us/library/cc837974.aspx
Merging Data from Multiple Workbooks into a Summary Workbook in Excel
Merge data from all workbooks in a folder
Merging a Range from Selected Workbooks
Merging a Range from Multiple Workbooks by Column
Merging a Range from Multiple Workbooks in a Folder with a Filter

You could do a Google search with “You Tube” and use the foollowing names, and/or, links:
YourProgrammingNetwork
ExcelVbalsFun
WiseOwlTutorials
ExcelScreencasts
ExcelVBAHelp
Andreas Thehos
LoeblComServices
Dinesh Kumar Takyar
VBA4Excel
I-Helped-U DoubleCheck
methodactor1982VBA
https://www.youtube.com/watch?v=ABXP...S5k4zsvnu2mkJC
https://www.youtube.com/watch?v=KHO5...3akx_gFMnpxTN5
https://www.youtube.com/watch?v=kd6Z...VH5Dq42RG9tlRP
https://www.youtube.com/watch?v=AIhK...suD6oNDaOk3vbR
https://www.youtube.com/watch?v=Z08z...Z_6brD5Gk1sVy_
https://www.youtube.com/user/ExcelVbaIsFun/playlists
https://www.youtube.com/watch?v=o_d8...lhXL_9m7EAgcMq
https://www.youtube.com/user/ExcelVB...ort=dd&view=50
https://www.youtube.com/playlist?lis...o2SEPBLLPGOyBz
https://www.youtube.com/watch?v=y_1e...7lleNVtNeAhBVC
https://www.youtube.com/watch?v=CDYk...007E847B3E6658

Some other Threads where VBA learning was discussed:
Basics of Excel VBA and Code writting
Excel VBA
How to find which worksheet my macro is launched from [SOLVED] - Page 2
How useful are YouTube tutorials for VBA

Sending mail from Excel with CDO
Sending mail from Excel with CDO

And, as your skills increase, try answering threads on sites like:
MrExcel.com | Excel Resources | Excel Solutions
http://www.excelforum.com
Excel Templates | Excel Add-ins and Excel Help with formulas and VBA Macros
Expert Microsoft Help, with all of the Microsoft Applications from Excel programming, Access training to our free Microsoft VBA Forums
Excel, Access, PowerPoint and Word VBA Macro Automation Help

If you are willing to spend money for the training, then something here should work for you...
http://www.amazon.com/s/?ie=UTF8&key...l_5givffg47i_b

Advanced Excel Training - Online Excel Course
http://www.udemy.com/advanced-excel/

Learn VBA Fast, Vol. I: Excel function design course, with practice exercises (The VBA Function Design Course Book 1)
http://www.amazon.co.uk/dp/B00M6E8MBW

Excel VBA Programmer Interview - Excel Test for interview
Excel VBA Programmer Interview

Excel tests
Excel Skills | Excel 2010 | Free Skills Test
Skills Assessment / Training Needs Analysis (TNA)
https://www.wiziq.com/tests/ms-excel
 
Upvote 0
Here’s one way to do it.
1. Put 0 in in all cell in helper column
d.Value = 0 'put 0 in all cell in helper column

2. Delete 0 in vc where the cell intersect
If va(1, k) = vb(i, j) Then vc(i, k) = "" 'delete value in vc

VBA Code:
Sub a1173102b()
'https://www.mrexcel.com/board/threads/help-needed-to-make-this-macro-faster.1173102/
Dim c As Range, d As Range
Dim i As Long, j As Long, n As Long
Dim k As Long, rc As Long
Dim va, vb, vc, t

t = Timer
Application.ScreenUpdating = False
n = Range("C" & Rows.Count).End(xlUp).Row - 1
rc = Cells(8, Columns.Count).End(xlToLeft).Column

Set c = Range(Cells(10, "E"), Cells(n, rc)) 'E10:X25
Set d = c.Offset(, rc * 2 + 100) 'temporary helper column, change to suit

d.Value = 0 'put 0 in all cell in helper column

c.Clear
'copy format C to E10:X25 format
Range(Cells(10, "C"), Cells(n, "C")).Copy
c.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'copy format to temporary helper column
Range(Cells(6, "E"), Cells(6, rc)).Copy
d.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'populating array
va = Range(Cells(8, "E"), Cells(8, rc)) 'row 8: range E8:X8
vb = c.Offset(, c.Columns.Count + 2)    'range AA10:AP25, assuming 2 columns separate the 2 areas (i.e E10:X25 & AA10:AP25)
vc = d                                  'temporary helper column, all 0

For i = 1 To UBound(vb, 1)

    For j = 1 To UBound(vb, 2)
   
        If vb(i, j) <> "" Then
       
            For k = 1 To UBound(va, 2)
               
                If va(1, k) = vb(i, j) Then vc(i, k) = "" 'delete value in vc
           
            Next
       
        End If
   
    Next

Next

'populate result to temporary helper column
d = vc
d.Copy
'paste format from helper column to E10:X25 with SkipBlanks:=True
c.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=True, Transpose:=False

Application.CutCopyMode = False
d.Clear 'clear temporary helper column

Application.ScreenUpdating = True

Debug.Print "It's done in: " & Timer - t & " seconds"

End Sub

Here's the helper columns look like if you run the code up to this line:
'populate result to temporary helper column
d = vc


Book1
EWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQ
8
9
1000000000000000
11000000000000000
120000000000000
13000000000000000
1400000000000000
150000000000000000
1600000000
1700000000000000000
1800000000
19000000000000000000
20000000000000000
2100000000000000000
2200000000000000
230000000000000000
2400000000
25000000000000
26
27
Sheet2

Thanks. I worked for two days of google searching codes and modifying the codes .You really not only solved a big work of mine but also saved my time. I checked with your codes. it worked fine.
 
Upvote 0
If you want to learn VBA have a look this list of resources kindly compiled by @hiker95
What Is VBA?
VBA is an acronym for Visual Basic for Applications. VBA should not be confused with VB, which is standard Visual Basic. Visual Basic for Applications is a programming feature designed by Microsoft for use with their Microsoft Office

MrExcel's Products: Books, CDs, Podcasts Discuss topics related to Holy Macro! Products: Learn Excel from MrExcel, VBA and Macros for Microsoft Excel,Holy Macro! It's 2500 VBA Examples CD, Guerilla Data Analysis Using Microsoft Excel and Excel Knowledge Base CD and the MrExcel Podcasts.
MrExcel's Products: Books, CDs, Podcasts

There are over 1800 Excel videos/tutorials here:
http://www.youtube.com/user/ExcelIsFun

Getting Started with VBA.
DataPig Technologies

If you are serious about learning VBA try
http://www.add-ins.com/vbhelp.htm

Excel Tutorials and Tips - VBA - macros - training
MrExcel.com | Excel Resources | Excel Seminars | Excel Products

MrExcel's Excel Tutorial Listing
MrExcel.com | Excel Resources | Excel Seminars | Excel Products

Excel VBA MACRO Kick-start Course for absolute beginner

Free VBA Course
Free VBA Training Course

Excel 2007 VBA materials to learn here:
VBA for Excel 2007 tutorial-VBA programming?

The macro recorder actually is your friend but look here:
Beyond Excel's recorder

Introduction to Variables, Constants and Data Types
http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx

Here's a good primer on the scope of variables.
Understanding Scope

Using Variables in Excel VBA Macro Code
Excel VBA Variables. Using Variables in Excel VBA Macro Code

See David McRitchie's site if you just started with VBA
Getting Started with Macros and User Defined Functions

What is a VBA Module and How is a VBA Module Used?
What is a VBA Module and How is a VBA Module Used?

Events And Event Procedures In VBA
Events In Excel VBA

Here is a good introductory tutorial using a VBA Class:
Classes In VBA

There's a chapter on classes in VBA Developer's Handbook which is also good.
http://www.amazon.com/VBA-Developers.../dp/0782129781

Ron's Excel Tips
Excel for Windows Tips

Ron de Bruin's Mail from Excel and make/mail PDF files (Windows)
Mail from Excel and make/mail PDF files (Windows)

How do I create and use a PERSONAL file for my VBA code
How do I create and use a PERSONAL file for my VBA code

Anthony's Excel VBA Page - Excel Application - Excel Consultant - Excel Consulting (see 3 tutorials in Excel VBA Basic Tutorial Series)

BET: Microsoft Excel Visual Basic

Debugging VBA
Debugging VBA

Debug Excel VBA Macro Code
Debug Excel VBA Macro Code

TechBookReport - Debugging Excel VBA Code
TechBookReport - Debugging Excel VBA Code

Here are some general links on performance improvement:
https://www.soa.org/News-and-Publica...s42-roper.aspx
Optimize Slow VBA Code. Speed Up Efficient VBA Code/Macros
Excel VBA Performance Coding Best Practices - Office Blogs
https://msdn.microsoft.com/en-us/library/aa730921.aspx

Start at the beginning...

Creating An XLA Add-In For Excel, Writing User Defined Functions In VBA
Creating An XLA Add In

Build an Excel Add-In
VBA Tips: Build an Excel Add-In

Creating custom functions
http://office.microsoft.com/en-us/ex...117011033.aspx

Writing Your First VBA Function in Excel
http://www.exceltip.com/st/Writing_Y...Excel/631.html

VBA for Excel (Macros)
Excel Macros (VBA) Tutorial

Excel Macros Tutorial
Excel Macros (VBA) Tutorial

Excel Macros & Programming
EXCEL Macros Tutorial

VBA Lesson 11: VBA Code General Tips and General Vocabulary
http://www.excel-vba.com/vba-code-2-1-tips.htm

Excel VBA -- Adding Code to a Workbook
http://www.contextures.com/xlvba01.html

Beyond Excel's recorder

Helpful as a simple concise reference for the basics, and, using the macro recorder is endlessly powerful.
http://www.techonthenet.com/excel/cells/index.php

Learn to debug:
Debugging VBA

How To: Assign a Macro to a Button or Shape
How To: Assign a Macro to a Button or Shape - Peltier Tech Blog

User Form Creation
http://www.contextures.com/xlUserForm01.html

Build a UserForm for Excel
http://www.fontstuff.com/ebooks/free/fsuserforms.pdf

When To Use a UserForm & What to Use a UserForm For
When to use Userform & What To Use Them For. Excel Training VBA 2 lesson 2

UserForms in Excel VBA - UserForm Basics; Add Controls dynamically at run-time using the Add Method; UserForm Controls (A Snapshot)

Excel VBA how to Personalise the Ribbon
excel vba how to personalise the ribbon - Bing video

Excel Tutorials / Video Tutorials - Functions
http://www.contextures.com/xlFunctions02.html

How to insert Buttons, radio buttons and check boxes in Excel
How to insert Buttons, radio buttons and check boxes in Excel - Bing video

INDEX MATCH - Excel Index Function and Excel Match Function
http://www.contextures.com/xlFunctions03.html

Multi or two way vlook up and index match tutorial
http://www.get-digital-help.com/

Excel Data Validation
http://www.contextures.com/xlDataVal08.html#Larger
http://www.contextures.com/excel-dat...ation-add.html

Excel -- Data Validation -- Create Dependent Lists
http://www.contextures.com/xlDataVal02.html

Create dependent drop down lists containing unique distinct values in excel | Get Digital Help - Microsoft Excel resource

Your Quick Reference to Microsoft Excel Solutions
XL-CENTRAL.COM : For your Microsoft Excel Solutions

New! Excel Recorded Webinars
DataPig Technologies

MS Excel: VBA Functions - Listed by Category
MS Excel: ALL Formulas/Functions - Listed by Category

Fuzzy Matching - new version plus explanation
Fuzzy Matching - new version plus explanation

Programming The VBA Editor - Created by Chip Pearson at Pearson Software Consulting LLC
This page describes how to write code that modifies or reads other VBA code.
Programming In The VBA Editor

VBA and Macros for Microsoft Excel, by Bill Jelen "Mr.Excel" and Tracy Syrstad

Excel Hacks 100 Industrial-Strength Tips & Tools, by David & Traina Hawley

VBA and Macros for Microsoft Excel 2007, by Bill Jelen "Mr.Excel" and Tracy Syrstad

John Walkenbach's power programming with Excel books.

Excel 2010 Power Programming with VBA, Mr. Spreadsheet's Bookshelf

by Stephen/ Bovey, Rob/ Green, John Bullen (Paperback - Feb 11, 2005)
Professional Excel Development

by Rob Bovey, Stephen Bullen, John Green, and Robert Rosenberg (Paperback - Sep 26, 2001)
Excel 2002 VBA: Programmers Reference

Professional Excel Development by Rob Bovey, Dennis Wallentin, Stephen Bullen, & John Green

DonkeyOte: My Recommended Reading, Volatility
Volatile Excel Functions -Decision Models

A list of Reference Books
AJP Excel Information

Sumproduct
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

Arrays
VBA Array Basics
VBA Arrays
Excel: Introduction to Array Formulas - Xtreme Visual Basic Talk
Excel VBA Lesson 21: Array in Excel VBA
The Complete Guide to Using Arrays in Excel VBA - Excel Macro Mastery

Array Dimensions in Visual Basic - Working with Dimensions (code and graphics)
http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx

Visual Basic Array Tutorial written by Adam Wehmann
Visual Basic Arrays Tutorial

Shortcut Keys in Excel 2000 through 2007

Pivot Intro
Using Pivot Tables in Microsoft Excel - Peltier Tech Blog
Office 2010 Class #36: Excel PivotTables Pivot Tables 15 examples (Data Analysis) - YouTube
http://www.youtube.com/watch?v=qMGILHiLqr0
Getting Started with Pivot Tables
http://www.contextures.com/xlPivot01.html#Start
Overview of PivotTable and PivotChart reports
http://office.microsoft.com/en-gb/ex...010342752.aspx
Build a Pivot Table in Excel VBA
Build a Pivot Table in Excel VBA : Microsoft Excel

Excel 2013 PowerPivot Basics #01: Introduction To PowerPivot for Excel 2013 - YouTube

Conditional Formatting
http://office.microsoft.com/en-001/e...102809768.aspx

Email from XL - VBA
Mail from Excel example pages

Outlook VBA
Writing VBA code for Microsoft Outlook

Mail a message to each person in a range
Mail a message to each person in a range

Excel Function Dictionary by Peter Noneley
http://www.xlfdic.com/
http://www.hoffits.com/

Function Translations
Excel function name translations - Dictionary Chart Front Page

Dynamic Named Ranges
http://www.contextures.com/xlNames01.html

How to create Excel Dashboards
http://www.contextures.com/excel-dashboards.html
Excel Dashboards - Templates, Tutorials, Downloads and Examples | Chandoo.org - Learn Microsoft Excel Online
Excel Dashboards - Templates, Tutorials, Downloads and Examples | Chandoo.org - Learn Microsoft Excel Online
Free Microsoft Excel Dashboard Widgets to Download
Gauge

Excel Dashboard / Scorecard Ebook
http://www.qimacros.com/excel-dashboard-scorecard.html

Mike Alexander from Data Pig Technologies
http://www.amazon.com/Excel-2007-Das...5564958&sr=1-1

Templates
CPearson.com Topic Index
http://www.contextures.com/excel-tem...lf-scores.html
Free Microsoft Excel Template Links & Search Engine

Financial Model Template
https://www.youtube.com/results?sear...finance&page=1

Microsoft Excel Cascading Listboxes Tutorial
http://www.youtube.com/watch?v=YAMvLJRwZdI

Date & Time stamping:
McGimpsey & Associates : Excel : Time and date stamps

Get Formula / Formats thru custom functions:
Show FORMULA or FORMAT of another cell

A nice informative MS article "Improving Performance in Excel 2007"
http://msdn.microsoft.com/en-us/library/aa730921.aspx

Progress Meters
Progress meters
http://www.xcelfiles.com/ProgressBar.html

How to convert text to numbers in Excel
http://support.microsoft.com/kb/291047

How to parse data from the web - Brett Fret has a video in YouTube
http://www.youtube.com/watch?v=6H7tBL97orE

Excel VBA MAC shortcuts
Mac Shortcuts for Excel

Macintosh Keyboard Shortcuts to use in Microsoft Excel
http://office.microsoft.com/en-us/ma...102927337.aspx

http://office.microsoft.com/en-us/ex...010073848.aspx

Excel VLOOKUP Multiple Sheets • My Online Training Hub

Wise Owl Tutorials
https://www.youtube.com/playlist?lis...3akx_gFMnpxTN5

http://msdn.microsoft.com/en-us/library/cc837974.aspx
Merging Data from Multiple Workbooks into a Summary Workbook in Excel
Merge data from all workbooks in a folder
Merging a Range from Selected Workbooks
Merging a Range from Multiple Workbooks by Column
Merging a Range from Multiple Workbooks in a Folder with a Filter

You could do a Google search with “You Tube” and use the foollowing names, and/or, links:
YourProgrammingNetwork
ExcelVbalsFun
WiseOwlTutorials
ExcelScreencasts
ExcelVBAHelp
Andreas Thehos
LoeblComServices
Dinesh Kumar Takyar
VBA4Excel
I-Helped-U DoubleCheck
methodactor1982VBA
https://www.youtube.com/watch?v=ABXP...S5k4zsvnu2mkJC
https://www.youtube.com/watch?v=KHO5...3akx_gFMnpxTN5
https://www.youtube.com/watch?v=kd6Z...VH5Dq42RG9tlRP
https://www.youtube.com/watch?v=AIhK...suD6oNDaOk3vbR
https://www.youtube.com/watch?v=Z08z...Z_6brD5Gk1sVy_
https://www.youtube.com/user/ExcelVbaIsFun/playlists
https://www.youtube.com/watch?v=o_d8...lhXL_9m7EAgcMq
https://www.youtube.com/user/ExcelVB...ort=dd&view=50
https://www.youtube.com/playlist?lis...o2SEPBLLPGOyBz
https://www.youtube.com/watch?v=y_1e...7lleNVtNeAhBVC
https://www.youtube.com/watch?v=CDYk...007E847B3E6658

Some other Threads where VBA learning was discussed:
Basics of Excel VBA and Code writting
Excel VBA
How to find which worksheet my macro is launched from [SOLVED] - Page 2
How useful are YouTube tutorials for VBA

Sending mail from Excel with CDO
Sending mail from Excel with CDO

And, as your skills increase, try answering threads on sites like:
MrExcel.com | Excel Resources | Excel Solutions
http://www.excelforum.com
Excel Templates | Excel Add-ins and Excel Help with formulas and VBA Macros
Expert Microsoft Help, with all of the Microsoft Applications from Excel programming, Access training to our free Microsoft VBA Forums
Excel, Access, PowerPoint and Word VBA Macro Automation Help

If you are willing to spend money for the training, then something here should work for you...
http://www.amazon.com/s/?ie=UTF8&key...l_5givffg47i_b

Advanced Excel Training - Online Excel Course
http://www.udemy.com/advanced-excel/

Learn VBA Fast, Vol. I: Excel function design course, with practice exercises (The VBA Function Design Course Book 1)
http://www.amazon.co.uk/dp/B00M6E8MBW

Excel VBA Programmer Interview - Excel Test for interview
Excel VBA Programmer Interview

Excel tests
Excel Skills | Excel 2010 | Free Skills Test
Skills Assessment / Training Needs Analysis (TNA)
https://www.wiziq.com/tests/ms-excel
Thanks for your reply. i really loved working in excel after watching excelisfun and mrexcel's videos since 2013. Im not IT tech but love to work in excel for business work of mine and also i encourage friends of mine to use excel for their business purpose because of this forum. I really thank you guys for your help and suggestions.
 
Upvote 0
Thanks. I worked for two days of google searching codes and modifying the codes .You really not only solved a big work of mine but also saved my time. I checked with your codes. it worked fine.
You're welcome, glad to help & thanks for the feedback. :)
 
Upvote 0
@Sathya89
I found that even if add more values above 16 at the right most range. The codes work fine.

Do you mean using your sample in post 1 you can add data in column after column AP?
Actually it won't work because the code assume that the 2 areas has the same size (i.e E10:X25 & AA10:AP25). The code defines the second area in this line:
vb = c.Offset(, c.Columns.Count + 2) 'range AA10:AP25, assuming 2 columns separate the 2 areas (i.e E10:X25 & AA10:AP25)
 
Upvote 0
@Sathya89


Do you mean using your sample in post 1 you can add data in column after column AP?
Actually it won't work because the code assume that the 2 areas has the same size (i.e E10:X25 & AA10:AP25). The code defines the second area in this line:
vb = c.Offset(, c.Columns.Count + 2) 'range AA10:AP25, assuming 2 columns separate the 2 areas (i.e E10:X25 & AA10:AP25)
i mean that if i write 17 on AQ column for intersection.The code works fine without any problem.
 
Upvote 0
i mean that if i write 17 on AQ column for intersection.The code works fine without any problem.
OK, that's fine.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,030
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top