SlideShare une entreprise Scribd logo
1  sur  15
macros 
Saving and Running 
Many of the useful Excel macros you’ll find on AcceleratedSEM.com - and 
on the internet - are posted as raw text. For this reason, it’s useful to 
know how to deploy this code to your instance of Excel.
macros 
Saving and Running 
- Where to paste your macro code in Excel. 
- How to save that macro so it can be used in any workbook. 
- How to make a customized menu button for your new macro.
First: A bit about Excel macro code 
Excel macros are written in a programming language called Visual Basic 
for Applications (VBA). Here’s an example snippet: 
Sub Hyperlinker() 
Dim rng As Range, workingRng As Range 
Set workingRng = Application.Selection 
'Code to set boundaries for workingRng, in case user selects entire row, column, or sheet 
Set workingRng = Range(Cells(workingRng.Row, workingRng.Column), 
Cells(lastRowInColumn(workingRng.Column), lastColumnInRow(workingRng.Row))) 
For Each rng In workingRng 
Application.ActiveSheet.Hyperlinks.Add rng, rng.Value 
Next rng 
End Sub 
Private Function lastRowInColumn(columnRef As Long) As Long 
lastRowInColumn = Cells(65536, columnRef).End(xlUp).Row 
End Function 
Private Function lastColumnInRow(rowRef As Long) As Long 
lastColumnInRow = Cells(rowRef, Columns.Count).End(xlToLeft).Column 
End Function 
When this code is executed as an Excel macro, it turns a selection of 
plain text URLs into clickable hyperlinks. It’s useful for working with PPC 
campaign builds, product feeds, and many analytics reports.
Before we get started, a word of warning … 
… never run VBA code that you suspect may 
be malicious. Doing so can jeopardize your 
data and your security.
Open a new Excel workbook and click Developer > Visual Basic (all the way left). 
The Visual Basic Editor (VBE) will open in a new window.
From the VBE’s menu, select Insert > Module 
A textbox window will appear inside the Visual Basic Editor.
In the new blank textbox window, we’ll paste our macro code. 
If you already have a snippet of macro code that you want to implement, 
you can use that. 
Otherwise, we’ll use the example code from earlier - the macro that 
creates hyperlinks from plain text URLs. Click here to retrieve and copy 
that code from GitHub.
Paste the code into the textbox. 
If you used the example code, your window should look like this:
Still in the Visual 
Basic Editor, 
File >> Save 
or 
CTRL+S 
and save as an 
Excel Add-In file 
(*.xlam). 
I’ve saved my 
project as 
newTool.xlam
Close the Visual Basic Editor. 
Back in your Excel workbook, click Developer >> Add-Ins 
In the resulting dialog box, check the box 
that corresponds to the Excel Add-In you 
just saved (in my case, newTool.xlam). 
If you don’t see your Add-In, you can click 
Browse and locate it manually.
Sweet! Our new Add-In, and the macro code it 
contains, is now ready to be used in every instance of 
Excel. 
But before we’re done, we want to make a convenient 
button for using that macro – the same way we’d use 
any of Excel’s built-in tools.
Start by clicking File >> Options
Under the Customize Ribbon menu, create a New Tab and New Group. 
Select Macros from the dropdown on the left and add your macro to the new group. 
(If two Hyperlinker macros are visible, hover over them with your cursor to show their path and choose the one saved as an .xlam)
Your macro is now available under it’s own tab in the Ribbon. 
You also may have noticed on the preceding screen that you can customize the 
name and appearance of your tab. After some finagling, mine looks like this: 
Whatever works for you 
Nice work! As a reward, here’s a picture of a puppy: 
Also, you’ve now got a useful tool that will hopefully 
make your life a little easier & more productive! 
For a demo of the hyperlinker snippet at work, click here. 
Next steps: Explore more Excel SEM tools.

Contenu connexe

En vedette

Pivot table presentation
Pivot table presentationPivot table presentation
Pivot table presentationSha Tibnjn
 
Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft ExcelEric Metelka
 
Advanced Excel &Basic Excel Training
Advanced Excel &Basic Excel TrainingAdvanced Excel &Basic Excel Training
Advanced Excel &Basic Excel Trainingaarkex
 
WizMantra- 20 Tips to learn English at home
WizMantra- 20 Tips to learn English at homeWizMantra- 20 Tips to learn English at home
WizMantra- 20 Tips to learn English at homewizmantra
 
Functions and formulas of ms excel
Functions and formulas of ms excelFunctions and formulas of ms excel
Functions and formulas of ms excelmadhuparna bhowmik
 
ExQuiz Me - 2017 (Grand Finale)
ExQuiz Me - 2017 (Grand Finale)ExQuiz Me - 2017 (Grand Finale)
ExQuiz Me - 2017 (Grand Finale)Somnath Chanda
 
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATIONMS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATIONMridul Bansal
 
Microsoft word basics ppt
Microsoft word basics pptMicrosoft word basics ppt
Microsoft word basics pptjdbutler13
 

En vedette (10)

Pivot table
Pivot tablePivot table
Pivot table
 
Pivot table presentation
Pivot table presentationPivot table presentation
Pivot table presentation
 
Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft Excel
 
Excel ch10
Excel ch10Excel ch10
Excel ch10
 
Advanced Excel &Basic Excel Training
Advanced Excel &Basic Excel TrainingAdvanced Excel &Basic Excel Training
Advanced Excel &Basic Excel Training
 
WizMantra- 20 Tips to learn English at home
WizMantra- 20 Tips to learn English at homeWizMantra- 20 Tips to learn English at home
WizMantra- 20 Tips to learn English at home
 
Functions and formulas of ms excel
Functions and formulas of ms excelFunctions and formulas of ms excel
Functions and formulas of ms excel
 
ExQuiz Me - 2017 (Grand Finale)
ExQuiz Me - 2017 (Grand Finale)ExQuiz Me - 2017 (Grand Finale)
ExQuiz Me - 2017 (Grand Finale)
 
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATIONMS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATION
 
Microsoft word basics ppt
Microsoft word basics pptMicrosoft word basics ppt
Microsoft word basics ppt
 

Dernier

From Chance to Choice - Tactical Link Building for International SEO
From Chance to Choice - Tactical Link Building for International SEOFrom Chance to Choice - Tactical Link Building for International SEO
From Chance to Choice - Tactical Link Building for International SEOSzymon Słowik
 
What are the 4 characteristics of CTAs that convert?
What are the 4 characteristics of CTAs that convert?What are the 4 characteristics of CTAs that convert?
What are the 4 characteristics of CTAs that convert?Juan Pineda
 
pptx.marketing strategy of tanishq. pptx
pptx.marketing strategy of tanishq. pptxpptx.marketing strategy of tanishq. pptx
pptx.marketing strategy of tanishq. pptxarsathsahil
 
VIP Call Girls In Green Park 9654467111 Escorts Service
VIP Call Girls In Green Park 9654467111 Escorts ServiceVIP Call Girls In Green Park 9654467111 Escorts Service
VIP Call Girls In Green Park 9654467111 Escorts ServiceSapana Sha
 
ASO Process: What is App Store Optimization
ASO Process: What is App Store OptimizationASO Process: What is App Store Optimization
ASO Process: What is App Store OptimizationAli Raza
 
Storyboards for my Final Major Project Video
Storyboards for my Final Major Project VideoStoryboards for my Final Major Project Video
Storyboards for my Final Major Project VideoSineadBidwell
 
What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...
What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...
What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...Ahrefs
 
Mastering SEO in the Evolving AI-driven World
Mastering SEO in the Evolving AI-driven WorldMastering SEO in the Evolving AI-driven World
Mastering SEO in the Evolving AI-driven WorldScalenut
 
Call Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCR
Call Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCRCall Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCR
Call Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCRlizamodels9
 
DGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdf
DGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdfDGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdf
DGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdfDemandbase
 
Red bull marketing presentation pptxxxxx
Red bull marketing presentation pptxxxxxRed bull marketing presentation pptxxxxx
Red bull marketing presentation pptxxxxx216310017
 
Master the Art of Digital Recruitment in Asia.pdf
Master the Art of Digital Recruitment in Asia.pdfMaster the Art of Digital Recruitment in Asia.pdf
Master the Art of Digital Recruitment in Asia.pdfHigher Education Marketing
 
Most Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdf
Most Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdfMost Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdf
Most Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdfCIO Business World
 
DIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdf
DIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdfDIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdf
DIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdfmayanksharma0441
 
Fiverr's Product Marketing Interview Assignment
Fiverr's Product Marketing Interview AssignmentFiverr's Product Marketing Interview Assignment
Fiverr's Product Marketing Interview AssignmentFarrel Brest
 
Influencer Marketing Power point presentation
Influencer Marketing  Power point presentationInfluencer Marketing  Power point presentation
Influencer Marketing Power point presentationdgtivemarketingagenc
 
The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024
The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024
The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024CIO Business World
 
Snapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdf
Snapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdfSnapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdf
Snapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdfEastern Online-iSURVEY
 
McDonald's: A Journey Through Time (PPT)
McDonald's: A Journey Through Time (PPT)McDonald's: A Journey Through Time (PPT)
McDonald's: A Journey Through Time (PPT)DEVARAJV16
 
Fueling A_B experiments with behavioral insights (1).pdf
Fueling A_B experiments with behavioral insights (1).pdfFueling A_B experiments with behavioral insights (1).pdf
Fueling A_B experiments with behavioral insights (1).pdfVWO
 

Dernier (20)

From Chance to Choice - Tactical Link Building for International SEO
From Chance to Choice - Tactical Link Building for International SEOFrom Chance to Choice - Tactical Link Building for International SEO
From Chance to Choice - Tactical Link Building for International SEO
 
What are the 4 characteristics of CTAs that convert?
What are the 4 characteristics of CTAs that convert?What are the 4 characteristics of CTAs that convert?
What are the 4 characteristics of CTAs that convert?
 
pptx.marketing strategy of tanishq. pptx
pptx.marketing strategy of tanishq. pptxpptx.marketing strategy of tanishq. pptx
pptx.marketing strategy of tanishq. pptx
 
VIP Call Girls In Green Park 9654467111 Escorts Service
VIP Call Girls In Green Park 9654467111 Escorts ServiceVIP Call Girls In Green Park 9654467111 Escorts Service
VIP Call Girls In Green Park 9654467111 Escorts Service
 
ASO Process: What is App Store Optimization
ASO Process: What is App Store OptimizationASO Process: What is App Store Optimization
ASO Process: What is App Store Optimization
 
Storyboards for my Final Major Project Video
Storyboards for my Final Major Project VideoStoryboards for my Final Major Project Video
Storyboards for my Final Major Project Video
 
What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...
What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...
What I learned from auditing over 1,000,000 websites - SERP Conf 2024 Patrick...
 
Mastering SEO in the Evolving AI-driven World
Mastering SEO in the Evolving AI-driven WorldMastering SEO in the Evolving AI-driven World
Mastering SEO in the Evolving AI-driven World
 
Call Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCR
Call Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCRCall Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCR
Call Girls In Aerocity Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delhi NCR
 
DGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdf
DGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdfDGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdf
DGR_Digital Advertising Strategies for a Cookieless World_Presentation.pdf
 
Red bull marketing presentation pptxxxxx
Red bull marketing presentation pptxxxxxRed bull marketing presentation pptxxxxx
Red bull marketing presentation pptxxxxx
 
Master the Art of Digital Recruitment in Asia.pdf
Master the Art of Digital Recruitment in Asia.pdfMaster the Art of Digital Recruitment in Asia.pdf
Master the Art of Digital Recruitment in Asia.pdf
 
Most Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdf
Most Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdfMost Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdf
Most Influential HR Leaders Leading the Corporate World, 2024 (Final file).pdf
 
DIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdf
DIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdfDIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdf
DIGITAL MARKETING STRATEGY_INFOGRAPHIC IMAGE.pdf
 
Fiverr's Product Marketing Interview Assignment
Fiverr's Product Marketing Interview AssignmentFiverr's Product Marketing Interview Assignment
Fiverr's Product Marketing Interview Assignment
 
Influencer Marketing Power point presentation
Influencer Marketing  Power point presentationInfluencer Marketing  Power point presentation
Influencer Marketing Power point presentation
 
The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024
The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024
The 10 Most Inspirational Leaders LEADING THE WAY TO SUCCESS, 2024
 
Snapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdf
Snapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdfSnapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdf
Snapshot of Consumer Behaviors of March 2024-EOLiSurvey (EN).pdf
 
McDonald's: A Journey Through Time (PPT)
McDonald's: A Journey Through Time (PPT)McDonald's: A Journey Through Time (PPT)
McDonald's: A Journey Through Time (PPT)
 
Fueling A_B experiments with behavioral insights (1).pdf
Fueling A_B experiments with behavioral insights (1).pdfFueling A_B experiments with behavioral insights (1).pdf
Fueling A_B experiments with behavioral insights (1).pdf
 

Saving and Running Excel Macros

  • 1. macros Saving and Running Many of the useful Excel macros you’ll find on AcceleratedSEM.com - and on the internet - are posted as raw text. For this reason, it’s useful to know how to deploy this code to your instance of Excel.
  • 2. macros Saving and Running - Where to paste your macro code in Excel. - How to save that macro so it can be used in any workbook. - How to make a customized menu button for your new macro.
  • 3. First: A bit about Excel macro code Excel macros are written in a programming language called Visual Basic for Applications (VBA). Here’s an example snippet: Sub Hyperlinker() Dim rng As Range, workingRng As Range Set workingRng = Application.Selection 'Code to set boundaries for workingRng, in case user selects entire row, column, or sheet Set workingRng = Range(Cells(workingRng.Row, workingRng.Column), Cells(lastRowInColumn(workingRng.Column), lastColumnInRow(workingRng.Row))) For Each rng In workingRng Application.ActiveSheet.Hyperlinks.Add rng, rng.Value Next rng End Sub Private Function lastRowInColumn(columnRef As Long) As Long lastRowInColumn = Cells(65536, columnRef).End(xlUp).Row End Function Private Function lastColumnInRow(rowRef As Long) As Long lastColumnInRow = Cells(rowRef, Columns.Count).End(xlToLeft).Column End Function When this code is executed as an Excel macro, it turns a selection of plain text URLs into clickable hyperlinks. It’s useful for working with PPC campaign builds, product feeds, and many analytics reports.
  • 4. Before we get started, a word of warning … … never run VBA code that you suspect may be malicious. Doing so can jeopardize your data and your security.
  • 5. Open a new Excel workbook and click Developer > Visual Basic (all the way left). The Visual Basic Editor (VBE) will open in a new window.
  • 6. From the VBE’s menu, select Insert > Module A textbox window will appear inside the Visual Basic Editor.
  • 7. In the new blank textbox window, we’ll paste our macro code. If you already have a snippet of macro code that you want to implement, you can use that. Otherwise, we’ll use the example code from earlier - the macro that creates hyperlinks from plain text URLs. Click here to retrieve and copy that code from GitHub.
  • 8. Paste the code into the textbox. If you used the example code, your window should look like this:
  • 9. Still in the Visual Basic Editor, File >> Save or CTRL+S and save as an Excel Add-In file (*.xlam). I’ve saved my project as newTool.xlam
  • 10. Close the Visual Basic Editor. Back in your Excel workbook, click Developer >> Add-Ins In the resulting dialog box, check the box that corresponds to the Excel Add-In you just saved (in my case, newTool.xlam). If you don’t see your Add-In, you can click Browse and locate it manually.
  • 11. Sweet! Our new Add-In, and the macro code it contains, is now ready to be used in every instance of Excel. But before we’re done, we want to make a convenient button for using that macro – the same way we’d use any of Excel’s built-in tools.
  • 12. Start by clicking File >> Options
  • 13. Under the Customize Ribbon menu, create a New Tab and New Group. Select Macros from the dropdown on the left and add your macro to the new group. (If two Hyperlinker macros are visible, hover over them with your cursor to show their path and choose the one saved as an .xlam)
  • 14. Your macro is now available under it’s own tab in the Ribbon. You also may have noticed on the preceding screen that you can customize the name and appearance of your tab. After some finagling, mine looks like this: Whatever works for you 
  • 15. Nice work! As a reward, here’s a picture of a puppy: Also, you’ve now got a useful tool that will hopefully make your life a little easier & more productive! For a demo of the hyperlinker snippet at work, click here. Next steps: Explore more Excel SEM tools.