Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Verify Column Letter Selected

I have a inputbox that prompts the user to enter a column letter so that a
script can run on all data in that column. The problem I have is that user
some times fat fingers this and enters things like "A3" or "A3E" Is there
anyway to check to make sure what the user inputs is a valid column letter?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Verify Column Letter Selected

Don't use inputbox, use application.inputbox

dim myRng as range
set myrng = nothing
on error resume next
set myrng _
= application.inputbox(Prompt:="select a single cell", type:=8).cells(1)
on error goto 0

if myrng is nothing then
'user hit cancel, what should happen?
else
set myrng = myrng.entirecolumn
or maybe...
set myrng = intersect(myrng.parent.usedrange, myrng.entirecolumn)
'do something
end if



jutlaux wrote:

I have a inputbox that prompts the user to enter a column letter so that a
script can run on all data in that column. The problem I have is that user
some times fat fingers this and enters things like "A3" or "A3E" Is there
anyway to check to make sure what the user inputs is a valid column letter?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Verify Column Letter Selected

Either use Application.Inputbox Type:=8 so that the user can select the range.

OR

Get the column as numbers and refer it as
Cells(row,column)

OR

If you are looking at last filled column use the below which will return
the last used column in row 1

lngLastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column

--
If this post helps click Yes
---------------
Jacob Skaria


"jutlaux" wrote:

I have a inputbox that prompts the user to enter a column letter so that a
script can run on all data in that column. The problem I have is that user
some times fat fingers this and enters things like "A3" or "A3E" Is there
anyway to check to make sure what the user inputs is a valid column letter?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Verify Column Letter Selected

If you are looking at last filled column use the below which will return
the last used column in row 1

lngLastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column


Or use this code which will return the last filled in column no matter what
row it occurs in...

LastUsedCol = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

--
Rick (MVP - Excel)


"Jacob Skaria" wrote in message
...
Either use Application.Inputbox Type:=8 so that the user can select the
range.

OR

Get the column as numbers and refer it as
Cells(row,column)

OR

If you are looking at last filled column use the below which will return
the last used column in row 1

lngLastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column

--
If this post helps click Yes
---------------
Jacob Skaria


"jutlaux" wrote:

I have a inputbox that prompts the user to enter a column letter so that
a
script can run on all data in that column. The problem I have is that
user
some times fat fingers this and enters things like "A3" or "A3E" Is there
anyway to check to make sure what the user inputs is a valid column
letter?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to verify selected data from drop-down list? PG Excel Worksheet Functions 1 September 5th 08 03:43 PM
How do I turn excel columns from column number to column letter? column Setting up and Configuration of Excel 1 April 29th 08 10:15 AM
How to replace column letter in refferences with a function using the old column letter? Dmitry Kopnichev Links and Linking in Excel 6 October 13th 05 09:09 AM
How to replace column letter in refferences with a function using the old column letter? Dmitry Kopnichev Excel Worksheet Functions 6 October 13th 05 09:09 AM
column header changed from letter to number, how return to letter Ron Excel Discussion (Misc queries) 2 May 9th 05 08:34 PM


All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"