myname = inputbox

Irek1974

Board Regular
Joined
Jul 17, 2009
Messages
64
Hi,
at the begining of my macro I have :
myname = InputBox("enter the name of the supplier") ' I input for example Supplier number 1

at the end of it I would like to input part of the name entered at the begining (for example Supplier) in cell A1

Can I use : inputbox ?
could somebody help me?
Irek
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Not quite sure what you are asking.
Are you asking how to put part of the Input Box value back in cell A1, something like:

Range("A1")=myname
or
Range("A1")=Left(myname,8)

If you are having trouble explaining it, maybe try providing a simple example of what you would like to happen.
 
Upvote 0
the problem is that the names of the suppliers will differ by length (number of letters). I need to input to A1 the first word from "myname" to which at the begining I entered for example : Nike - june 2009
In this case I need in A1 only NIKE

another example : I input in myname Samsung - July 2009. I need in A1 only Samsung


Not quite sure what you are asking.
Are you asking how to put part of the Input Box value back in cell A1, something like:

Range("A1")=myname
or
Range("A1")=Left(myname,8)

If you are having trouble explaining it, maybe try providing a simple example of what you would like to happen.
 
Upvote 0
if there is always a space and dash after what you are looking for in the cell then try this...

Code:
  Range("A1") = Left(myname, InStr(1, myname, " -") - 1)
 
Upvote 0
if there is always a space and dash after what you are looking for in the cell then try this...
That was the key piece of information that was missing. As long as you have some "rule" that defines what you want (i.e. everything up to the first space, or everything up to the dash), then something can be programmed to do that. We just needed to know what your rule was...
 
Upvote 0
thank you very much.
it helped

That was the key piece of information that was missing. As long as you have some "rule" that defines what you want (i.e. everything up to the first space, or everything up to the dash), then something can be programmed to do that. We just needed to know what your rule was...
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,782
Members
449,259
Latest member
rehanahmadawan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top