Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Business Applications
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor recovery router safe mode slow sound spyware tdlwsp.dll trojan vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
How to select a range in Excel using a cell value

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
Fadi's Avatar
Junior Member with 2 posts.
 
Join Date: Nov 2009
02-Nov-2009, 05:15 AM #1
How to select a range in Excel using a cell value
Hi,

I am a begginer in excel programing and i don't know how to use cell value inside range command in VB
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 9,329 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
02-Nov-2009, 05:33 AM #2
Fadi, welcome to the Forum.
Do you mean like this
cells(1,1)
which is range "A1"
or
Range(Cells(1, 1), Cells(3, 3)).Select
which selects the range A1 to C3

Did you know that if you open the VBA editor and click the Help it has it's own help which is different to the Excel Workbook help.
So when you type in the Editor's Help Search the key word Cells() it will describe for you what it is and how it works.
This applies to most VBA key words
__________________
OBP
I do not give up easily
Fadi's Avatar
Junior Member with 2 posts.
 
Join Date: Nov 2009
02-Nov-2009, 02:19 PM #3
Hi OBP

Thanks for your help but what needed wasn't the information you provided, may i should have explained more so please let me do so

I have cell with value changes according to a certain selection from the user, the user inputs a number and according to this number this cell gives the column number in which i want to select some cells

i don't know how to use this number to select the cells i want.

Thanks
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 9,329 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
03-Nov-2009, 07:50 AM #4
cells(1,Cells(1,1)).select
Which would use the value in Cell a1 to select the first cell of the Column that matches that value.
wedonttakecrap's Avatar
Junior Member with 7 posts.
 
Join Date: Nov 2009
Experience: Advanced
03-Nov-2009, 02:11 PM #5
If I understand this, the user enters a value, and you want to use that value to find a column corresponding to it elsewhere in the book?

If the user is entering the column number, then OBP's solution will work.

If you want to find the column in the sheet that matches the user entered value, then you probably don't need to hassle with VBA at all, and you can get by with the MATCH() function.

Syntax
MATCH(lookup_value,lookup_array,match_type)
it can be used to find an exact match (0), next lowest value(-1), or next highest value(1).

If it is something best left to VBA, I personally despise the syntax for VBA's find function and instead I'd probably use the WorksheetFunction property to call Match from inside my code, like this example:

answer = Application.WorksheetFunction.Match(UserValueCell, LookupRange,0)

I hope that helps.
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 07:02 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.