Help writing a Macro that require a selection?

meesha

New Member
Joined
Apr 4, 2015
Messages
7
Greetings!

I am at the very beginning stages of learning VBA, and I am a basic level excel user (I have messed with one or two formula's but nothing much).
I am working on a project, and need to know if there is a way to write a macro that requires an on-screen (with a mouse) selection of the cells you want to apply the macro to?

I would like to build a macro that completes multiple steps of a clean-up process quickly, however I need to be able to select different cells, and different columns, possibly in different workbooks to apply the macro to.

This forum is famous for its knowledgeable feedback. I appreciate any help you can give me!

Sincerely,

-Meesha:biggrin:
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Wow! That is exactly what I needed.
Now the hard question. Can you explain it in layman's terms so I can reuse the selection method with other recorded macros?
If I understand it correctly, it is some sort of "for next" loop; but I do not understand what the "c" represents?
 
Upvote 0
Quite simply, the c represents each "cell" in the range.
so, c could be replaced with cell.....but c is quicker and cleaner
Rich (BB code):
Sub Cost_Clean_Up() '
For Each cell In Selection
    c.Replace What:="K", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows
    c.Replace What:="M", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows
    c.Value = c.Value / 100
    c.Style = "Currency"
Next c
End Sub
 
Upvote 0
When you write "c" does excel read it as "cell"? Is is some sort of known abbreviation, or could "c" be replaced with any letter or number?
 
Upvote 0
Also, (warning, newbie question!) do you have a recommended course of study for learning VBA for excel? I am a visual and hands on learner, and I like to know "why".
 
Upvote 0
firstly, C is just a variable, you could use any letter....But cell starts with c...:LOL:
As far as learning. Have a look at this list kindly compiled by Hiker95

Training / Books / Sites / Forums:

Training / Books / Sites

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

How to Learn to Write Macros
http://articles.excelyogi.com/playin...ba/2008/10/27/

How to use the macro recorder
Excel Yogi’s

Click here and scroll down to 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

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

What is a Visual Basic Module?
http://www.emagenit.com/VBA Folder...vba_module.htm

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
Getting Started with Macros and User Defined Functions

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

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

Where to paste code in VBE VBA
Introducing the Excel VBA Editor
Ask.com - What's Your Question?

VBA for Excel (Macros)
Excel Macros (VBA) 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

EXCEL Macros Tutorial
Getting Started with Macros and User Defined Functions
http://www.exceltip.com/excel_links.html

(livelessons video)
Excel VBA and Macros with MrExcel
ISBN: 0-7897-3938-0
http://www.amazon.com/Excel-Macros-M...7936479&sr=1-1

Learn to debug:
Debugging VBA

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

XL-CENTRAL.COM : For your Microsoft Excel Solutions

DataPig Technologies

Cascading queries

http://www.tushar-mehta.com/excel/ne...ing_dropdowns/

Excel VLOOKUP Function and VLOOKUP Example
http://www.contextures.com/xlFunctions02.html

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

http://www.contextures.com/xlDataVal02.html
http://www.contextures.com/xlDataVal05.html
http://www.contextures.com/xlDataVal08.html#Larger

Excel Data Validation - Add New Items
http://www.contextures.com/excel-dat...ation-add.html

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

Locating files containing VBA
Searching Files in Subfolders for VBA code string:
http://www.dailydoseofexcel.com/arch...a-code-string/

Re: Excel XP VBA code to search all macro code in Excel module for specific search string criteria | PC Review

Excel 2003 Power Programming with VBA (Excel Power Programming With Vba)
by John Walkenbach

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

Excel 2007 Book: you can try this...there is a try before you buy ebook available at this link…
Learn Excel 97 through 2007 from Mr Excel - Revised and Expanded Second Edition

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

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

VB & VBA in a Nutshell: The Language
(http://www.amazon.co.uk/VB-VBA-Nutsh...4671189&sr=1-2)

Writing Excel Macros with VBA
(http://www.amazon.co.uk/Writing-Exce...4671189&sr=1-3)

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

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

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

Arrays
Excel: Introduction to Array Formulas - Xtreme Visual Basic Talk

Pivot Intro
Using Pivot Tables in Microsoft Excel - Peltier Tech Blog

Sync Pivot Tables
http://www.mrexcel.com/forum/showthr...g+pivot+tables
Check out rorya's post at the very bottom of this link. It should do the trick:
http://www.experts-exchange.com/Soft..._22844558.html
Multiple pivot tables 1 filter to control all
http://www.excelforum.com/excel-prog...ntrol-all.html

Email from XL - VBA
Mail from Excel example pages

Outlook VBA
Writing VBA code for Microsoft Outlook

Function Dictionary
http://www.xlfdic.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

Excel Dashboard / Scorecard Ebook
Excel Dashboards and Scorecards Ebook | How to Create Dashboards in Excel

Templates
CPearson.com Topic Index
http://www.contextures.com/excel-tem...lf-scores.html

Mike Alexander from Data Pig Technologies
Excel 2007 Dashboards & Reports For Dummies

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

Simple short VBA for beginners with explanations
Julian's Excel Macro (VBA) Tips for Beginners
Forums
MrExcel.com | Excel Resources | Excel Seminars | Excel Products
Excel Help Forum
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
 
Upvote 0

Forum statistics

Threads
1,215,622
Messages
6,125,889
Members
449,270
Latest member
bergy32204

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