Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop mac malware memory monitor motherboard music network printer problem ram registry router server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit 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

Reply  
Thread Tools
Fadi's Avatar
Junior Member with 2 posts.
 
Join Date: Nov 2009
02-Nov-2009, 06: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 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
02-Nov-2009, 06: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, 03: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 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
03-Nov-2009, 08: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, 03: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

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:03 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.