Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Defining a name for selected columns using a user form

Status
Not open for further replies.

funkmonsteruk

IS-IT--Management
Feb 8, 2002
210
GB
I have a user form with 5 tickboxes on it representing columns A:E, a textbox in which the user can enter a name and a button which needs to assign the name to the columns selected using the tickboxes.

I want the user to be able to select which columns they want to define (add a name to) in the activeworksheet by selecting the relevant tickboxes on a userform, then enter a name into the textbox which will be used for amongst other things, defining a name for the selected columns and then to click the button to actually add the name to the selected columns.

Can anybody help with all or part of this process
 
Assuming tickboxes are called Col1-Col5. Use numbers instead of letters cos it saves later conversion

For the command button code:
dim mytick as control
for each mytick in controls
if Left(mytick.name,3) = "Col" then 'check it's one of the tickboxes
if mytick.value = true then 'check it's ticked
thecol = Val(right(mytick.name,1))'take the column number
set curcell = worksheet("Worksheet Name").cells(1,thecol)'allocate curcell to the cell
curcell.value = textbox1.text'write the textbox value to the cell
End if
end if
next


I prefer to allocate objects to cells out of habit, it could be done as easily with ranges.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top