Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Input Box selects a cell location to use in code

I have the following simple code:

ActiveCell.FormulaR1C1 = "=TRIM(RC[5])&RC[11]"

eg above concatenates the cells 5 & 11 columns along.

What I want is for the user, by way of an input box, to be able to choose
the columns, say 2 & 6.

Can anyone help with this please?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Input Box selects a cell location to use in code

This is one way:

firstCol = Application.InputBox("Enter First Column Number", "First Column",
Type:=1)
scndCol = Application.InputBox("Enter Second Column Number", "Second
Column", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[firstCol])&RC[scndCol]"


"Archie" wrote:

I have the following simple code:

ActiveCell.FormulaR1C1 = "=TRIM(RC[5])&RC[11]"

eg above concatenates the cells 5 & 11 columns along.

What I want is for the user, by way of an input box, to be able to choose
the columns, say 2 & 6.

Can anyone help with this please?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Input Box selects a cell location to use in code

Thanks, but I get application-defined of Object-defined error, so do I need
to add something else?

"JLGWhiz" wrote:

This is one way:

firstCol = Application.InputBox("Enter First Column Number", "First Column",
Type:=1)
scndCol = Application.InputBox("Enter Second Column Number", "Second
Column", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[firstCol])&RC[scndCol]"


"Archie" wrote:

I have the following simple code:

ActiveCell.FormulaR1C1 = "=TRIM(RC[5])&RC[11]"

eg above concatenates the cells 5 & 11 columns along.

What I want is for the user, by way of an input box, to be able to choose
the columns, say 2 & 6.

Can anyone help with this please?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Input Box selects a cell location to use in code

Option Explicit
Sub testme()
Dim FirstCol As Long
Dim ScndCol As Long

FirstCol = Application.InputBox("Enter First Column Number", _
"First Column", Type:=1)

ScndCol = Application.InputBox("Enter Second Column Number", _
"Second Column ", Type:=1)

ActiveCell.FormulaR1C1 = "=TRIM(RC[" & FirstCol & "])&RC[" & ScndCol & "]"

End Sub

Archie wrote:

Thanks, but I get application-defined of Object-defined error, so do I need
to add something else?

"JLGWhiz" wrote:

This is one way:

firstCol = Application.InputBox("Enter First Column Number", "First Column",
Type:=1)
scndCol = Application.InputBox("Enter Second Column Number", "Second
Column", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[firstCol])&RC[scndCol]"


"Archie" wrote:

I have the following simple code:

ActiveCell.FormulaR1C1 = "=TRIM(RC[5])&RC[11]"

eg above concatenates the cells 5 & 11 columns along.

What I want is for the user, by way of an input box, to be able to choose
the columns, say 2 & 6.

Can anyone help with this please?



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Input Box selects a cell location to use in code

Sorry about that, Archie. I don't work with Worksheet formulas that much.
Here is the corrected code.

Sub inptbx()
Dim firstCol As Long, scndCol As Long
firstCol = Application.InputBox("Enter First Column Number", "First
Column", Type:=1)
scndCol = Application.InputBox("Enter Second Column Number",
"SecondColumn ", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[" & firstCol & "]) & TRIM(RC[" &
scndCol & "])"
End Sub


"Archie" wrote:

Thanks, but I get application-defined of Object-defined error, so do I need
to add something else?

"JLGWhiz" wrote:

This is one way:

firstCol = Application.InputBox("Enter First Column Number", "First Column",
Type:=1)
scndCol = Application.InputBox("Enter Second Column Number", "Second
Column", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[firstCol])&RC[scndCol]"


"Archie" wrote:

I have the following simple code:

ActiveCell.FormulaR1C1 = "=TRIM(RC[5])&RC[11]"

eg above concatenates the cells 5 & 11 columns along.

What I want is for the user, by way of an input box, to be able to choose
the columns, say 2 & 6.

Can anyone help with this please?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Input Box selects a cell location to use in code

Thanks Guys, your help is fantastic.

"JLGWhiz" wrote:

Sorry about that, Archie. I don't work with Worksheet formulas that much.
Here is the corrected code.

Sub inptbx()
Dim firstCol As Long, scndCol As Long
firstCol = Application.InputBox("Enter First Column Number", "First
Column", Type:=1)
scndCol = Application.InputBox("Enter Second Column Number",
"SecondColumn ", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[" & firstCol & "]) & TRIM(RC[" &
scndCol & "])"
End Sub


"Archie" wrote:

Thanks, but I get application-defined of Object-defined error, so do I need
to add something else?

"JLGWhiz" wrote:

This is one way:

firstCol = Application.InputBox("Enter First Column Number", "First Column",
Type:=1)
scndCol = Application.InputBox("Enter Second Column Number", "Second
Column", Type:=1)
ActiveCell.FormulaR1C1 = "=TRIM(RC[firstCol])&RC[scndCol]"


"Archie" wrote:

I have the following simple code:

ActiveCell.FormulaR1C1 = "=TRIM(RC[5])&RC[11]"

eg above concatenates the cells 5 & 11 columns along.

What I want is for the user, by way of an input box, to be able to choose
the columns, say 2 & 6.

Can anyone help with this please?


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
Need an input box when user selects a value in a drop down box Susan Excel Worksheet Functions 4 September 8th 08 06:14 PM
Code for a button to change cell location Michael B Excel Discussion (Misc queries) 1 November 30th 07 04:30 PM
Pause code, wait for input, no input received, carry on with the code [email protected] Excel Programming 1 September 29th 05 12:19 PM
Is this possible...Filter list after user selects location Jan Excel Programming 3 March 31st 05 08:08 PM


All times are GMT +1. The time now is 09:16 PM.

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"