View Full Version : select 3 columns
asdzxc
04-22-2012, 04:09 AM
I want to select range(A2,C17) as attached "table" file.
I wrote the following macro which is not working:
Sub Macro4()
'
' Macro4 Macro
'
' Keyboard Shortcut: Ctrl+o
Dim LR As Long
LR = Range("B2").End(xlDown).Offset(3, 0).Select
Range("A2:C2", "C" & LR).Select
End Sub
What's wrong plse?
stanleydgrom
04-22-2012, 01:26 PM
asdzxc,
Try this change to your original code:
Option Explicit
Sub Macro4()
'
' Macro4 Macro
'
' Keyboard Shortcut: Ctrl+o
Dim LR As Long
LR = Range("B2").End(xlDown).Offset(3, 0).Row
Range("A2:C2", "C" & LR).Select
End Sub
Have a great day,
Stan
stanleydgrom
04-22-2012, 01:28 PM
asdzxc,
Training / Books / Sites as of 04/14/2012
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.
http://www.mrexcel.com/forum/forumdisplay.php?f=19 (http://www.mrexcel.com/forum/forumdisplay.php?f=19)
Getting Started with VBA.
http://www.datapigtechnologies.com/ExcelMain.htm (http://www.datapigtechnologies.com/ExcelMain.htm)
If you are serious about learning VBA try
http://www.add-ins.com/vbhelp.htm (http://www.add-ins.com/vbhelp.htm)
Excel Tutorials and Tips - VBA - macros - training http://www.mrexcel.com/articles.shtml (http://www.mrexcel.com/articles.shtml)
Here's a good primer on the scope of variables.
Scope Of Variables And Procedures (http://www.cpearson.com/excel/scope.aspx)
See David McRitchie's site if you just started with VBA http://www.mvps.org/dmcritchie/excel/getstarted.htm (http://www.mvps.org/dmcritchie/excel/getstarted.htm)
What is a Visual Basic Module?
http://www.emagenit.com/VBA%20Folder/what_is_a_vba_module.htm (http://www.emagenit.com/VBA%20Folder/what_is_a_vba_module.htm)
Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm (http://www.rondebruin.nl/code.htm)
Creating An XLA Add-In For Excel, Writing User Defined Functions In VBA
http://www.cpearson.com/excel/createaddin.aspx (http://www.cpearson.com/excel/createaddin.aspx)
How do I create a PERSONAL.XLS(B) or Add-in http://www.rondebruin.nl/personal.htm (http://www.rondebruin.nl/personal.htm)
Creating custom functions
http://office.microsoft.com/en-us/excel/HA011117011033.aspx (http://office.microsoft.com/en-us/excel/HA011117011033.aspx)
Writing Your First VBA Function in Excel http://www.exceltip.com/st/Writing_Your_First_VBA_Function_in_Excel/631.html (http://www.exceltip.com/st/Writing_Your_First_VBA_Function_in_Excel/631.html)
VBA for Excel (Macros)
http://www.excel-vba.com/excel-vba-contents.htm (http://www.excel-vba.com/excel-vba-contents.htm)
VBA Lesson 11: VBA Code General Tips and General Vocabulary
http://www.excel-vba.com/vba-code-2-1-tips.htm (http://www.excel-vba.com/vba-code-2-1-tips.htm)
Excel VBA -- Adding Code to a Workbook
http://www.contextures.com/xlvba01.html (http://www.contextures.com/xlvba01.html)
Learn to debug:
http://www.cpearson.com/excel/debug.htm (http://www.cpearson.com/excel/debug.htm)
How To: Assign a Macro to a Button or Shape
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/ (http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/)
User Form Creation
http://www.contextures.com/xlUserForm01.html (http://www.contextures.com/xlUserForm01.html) Excel Tutorials /
Video Tutorials - Functions
http://www.contextures.com/xlFunctions02.html (http://www.contextures.com/xlFunctions02.html)
INDEX MATCH - Excel Index Function and Excel Match Function http://www.contextures.com/xlFunctions03.html
Excel Data Validation
http://www.contextures.com/xlDataVal08.html#Larger
http://www.contextures.com/excel-data-validation-add.html
Your Quick Reference to Microsoft Excel Solutions http://www.xl-central.com/index.html
New! Excel Recorded Webinars http://www.datapigtechnologies.com/ExcelMain.htm (http://www.datapigtechnologies.com/ExcelMain.htm)
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. http://www.cpearson.com/Excel/vbe.aspx (http://www.cpearson.com/Excel/vbe.aspx)
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… by Stephen/ Bovey, Rob/ Green, John Bullen (Paperback - Feb 11, 2005) Professional Excel Development (http://www.amazon.com/Professional-Excel-Development-Stephen-Bullen/dp/B001E0MXXC/ref=sr_1_9?ie=UTF8&s=books&qid=1246574194&sr=8-9) by Rob Bovey, Stephen Bullen, John Green, and Robert Rosenberg (Paperback - Sep 26, 2001) Excel 2002 VBA: Programmers Reference (http://www.amazon.com/Excel-2002-VBA-Programmers-Reference/dp/0764543717/ref=sr_1_1?ie=UTF8&s=books&qid=1246574278&sr=8-1)
DonkeyOte: My Recommended Reading, Volatility http://www.decisionmodels.com/calcsecretsi.htm (http://www.decisionmodels.com/calcsecretsi.htm)
Sumproduct (http://www.xldynamic.com/source/xld.SUMPRODUCT.html)
http://www.xldynamic.com/source/xld.SUMPRODUCT.html (http://www.xldynamic.com/source/xld.SUMPRODUCT.html)
Arrays (http://www.xtremevbtalk.com/showthread.php?t=296012)
http://www.xtremevbtalk.com/showthread.php?t=296012 (http://www.xtremevbtalk.com/showthread.php?t=296012)
Pivot Intro (http://peltiertech.com/Excel/Pivots/pivotstart.htm)
http://peltiertech.com/Excel/Pivots/pivotstart.htm (http://peltiertech.com/Excel/Pivots/pivotstart.htm)
Email from XL - VBA (http://www.rondebruin.nl/sendmail.htm)
http://www.rondebruin.nl/sendmail.htm (http://www.rondebruin.nl/sendmail.htm)
Outlook VBA (http://www.outlookcode.com/article.aspx?ID=40)
http://www.outlookcode.com/article.aspx?ID=40 (http://www.outlookcode.com/article.aspx?ID=40)
Function Dictionary (http://www.xlfdic.com/)
http://www.xlfdic.com/ (http://www.xlfdic.com/)
Function Translations (http://www.piuha.fi/excel-function-name-translation/index.php?page=all-languages.html)
http://www.piuha.fi/excel-function-name-translation/ (http://www.piuha.fi/excel-function-name-translation/)
Dynamic Named Ranges (http://www.contextures.com/xlNames01.html)
http://www.contextures.com/xlNames01.html (http://www.contextures.com/xlNames01.html)
How to create Excel Dashboards
http://www.contextures.com/excel-dashboards.html (http://www.contextures.com/excel-dashboards.html)
http://chandoo.org/wp/excel-dashboards/ (http://chandoo.org/wp/excel-dashboards/)
http://chandoo.org/wp/management-dashboards-excel/ (http://chandoo.org/wp/management-dashboards-excel/) http://www.exceldashboardwidgets.com/ (http://www.exceldashboardwidgets.com/)
Excel Dashboard / Scorecard Ebook
http://www.qimacros.com/excel-dashboard-scorecard.html (http://www.qimacros.com/excel-dashboard-scorecard.html)
Mike Alexander from Data Pig Technologies
Excel 2007 Dashboards & Reports For Dummies (http://www.amazon.com/Excel-2007-Dashboards-Reports-Dummies/dp/0470228148/ref=sr_1_1?s=books&ie=UTF8&qid=1305564958&sr=1-1)
Templates
http://www.cpearson.com/Excel/Topic.aspx (http://www.cpearson.com/Excel/Topic.aspx)
http://www.contextures.com/excel-template-golf-scores.html (http://www.contextures.com/excel-template-golf-scores.html)
Date & Time stamping:
http://www.mcgimpsey.com/excel/timestamp.html
Get Formula / Formats thru custom functions:
http://dmcritchie.mvps.org/excel/formula.htm#GetFormat (http://dmcritchie.mvps.org/excel/formula.htm#GetFormat)
A nice informative MS article "Improving Performance in Excel 2007"
http://msdn.microsoft.com/en-us/library/aa730921.aspx (http://msdn.microsoft.com/en-us/library/aa730921.aspx)
Progress Meters
http://www.andypope.info/vba/pmeter.htm http://www.xcelfiles.com/ProgressBar.html
And, as your skills increase, try answering posts on sites like: http://www.mrexcel.com (http://www.mrexcel.com/)
http://www.excelforum.com (http://www.excelforum.com/)
http://www.ozgrid.com (http://www.ozgrid.com/)
http://www.vbaexpress.com (http://www.vbaexpress.com/)
http://www.excelfox.com (http://www.excelfox.com/)
asdzxc
04-22-2012, 05:34 PM
asdzxc,
Try this change to your original code:
Option Explicit
Sub Macro4()
'
' Macro4 Macro
'
' Keyboard Shortcut: Ctrl+o
Dim LR As Long
LR = Range("B2").End(xlDown).Offset(3, 0).Row
Range("A2:C2", "C" & LR).Select
End Sub
Have a great day,
Stan
It works.
Thank you, Stan
stanleydgrom
04-22-2012, 06:22 PM
asdzxc,
Thanks for the feedback.
You are very welcome. Glad I could help.
Come back anytime.
Have a great day,
Stan
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.