Adding Second Substitute Command
Jun 28, 2009Adding second substitute command
What I need to do is change this:
Adding second substitute command
What I need to do is change this:
I am playing around with the Forfiles command (being called from Excel via Shell)..
I can't for the life of me get it apply a second command (such as getting the file size of each file)..
For example:
VB:
Private Sub CommandButton1_Click()
Dim Z
Z = Split(CreateObject("wscript.shell").exec("cmd /c forfiles /P C:UsersapoDesktopTextFiles /S /M *.* /d
[Code]....
The end result being the filename and the filesize shown..
FYI This is cross posted on the VB Forums at [URL].....
I know that you can use the below code to add buttons to 2 of Excel's menu systems,
Code:
Application.CommandBars("Worksheet Menu Bar").Controls.Add
Application.CommandBars("Cell").Controls.Add
And this should add a command bar control of whatever type specified to either the Add-Ins tab of the ribbon or the right-click menu when clicking on a range of cells.
However, I would like to be able to add some command bar controls to the right-click menu when you click on a group of columns. Is this possible?
I just stuck on the basics. I want to add a new sheet through a macro and a button in the same. I am unable to make it dynamic. it is giving me an error:
I have a monthly log that I need to keep to track expenses and customers visited. The log is segmented into 12 parts corresponding with each month.
I need to be able to add multiple lines via an input box while maintaining the formulas and formatting of the 2 rows directly above the forms command button (because both lines are filled with a different color) but not the contents?
There will be 12 command buttons in all and the new rows should be added at the bottom (directly above where the button is)
I found this and it works to some extent.
Sub FromFormsCommandBar2()
Dim Btn As Button
with ActiveSheet
Set Btn = .Buttons(application.caller)
btn.topleftcell.entirerow.insert
end with
End Sub
I have built a Form which displays data from a spreadsheet. The user opens the form by clicking on a command button from the spreadsheet. The Form initially opens with the data from Row 4 of the spreadsheet (because this is the first row of the spreadsheet which contains the data for the form). The user can then sequentially access other rows in the spreadsheet by clicking on buttons in the Form which advance the extraction by one row.
I would like to add a command button to each row of the spreadsheet that would open up the Form and set the values in the Form to the same row which the command sits on.
Workbook performs perfectly 95% of the time but every now and again I have this issue where the formular do not calculate (it is set to automatic).
I have a workaround of doing a find and replace across all the worksheets of "=" replaced with "=" and this solves the issue.
The problem I am having is that some of the sheets are protected and some are not. The code I am using for the find and replace is as follows...
VB:
Option Explicit
Sub ChgInfo()
Dim WS As Worksheet
Dim Search As String
Dim Replacement As String
[Code] .....
I need to add to this code the unprotect command and then reprotect only the originally protected sheets?
I am sure these is a better way of doing this but im really short on time. This issue only occurs 5% of the time. the other 95% the formula all calculate fine!
I just need a way of doing the find and replace for = to = across all sheets in the workbook regardless of the sheet protection!!
I have a macro which I use to do all sorts of routine things on a spreadsheet for my employees. (you guys helped me with that too. thanks)
I would like to add a command button to this sheet to run series of code and I want to add this to the final step of a macro.
Question, is there a series of code, which would
1. create the command button on the active sheet, and
2. add the required code to the command button, and
3. embed that button and code onto the active sheet all at once.
?
I need to do this regularly so it is a currently manual process I am trying to replace.
Ex. of code I want placed:
Rows("1:1").Select
Selection.Font.Bold = True
This is not the exact code which I will use, but it will help me to understand what I would have to do to make it work.
I have a user form with combo boxes. The user selects items from the combo box and when they click the command button the selection is written to the spreadsheet. Each time the button is clicked it adds an item to the sheet making a list of items. I am trying to assign a number to each item when the command button is clicked so I have numbered list. Here is my code so far:
Private Sub cmdbtnAdd_Click()
Dim RowCount As String
'Writes user inputs to Active Worksheet when Add Item Button is clicked.
RowCount = Worksheets("Sheet1").Range
("A1").CurrentRegion.Rows.Count
With Worksheets("Sheet1").Range("A1")
.Offset(RowCount, 0).Value = ' This is where I have been trying to code in the numbering
.Offset(RowCount, 1).Value = Me.Combobox1
.Offset(RowCount, 2).Value = Me.ComboBox2
End With
End Sub
CASH BK
CASHIERS
DATE
CASH
TOTAL
DIFF
SALES
GBP
AR
GBP
AR
GBP
[code]....
above is the sheet template we use on a monthly basis. I would to like to use a command button which will run a macro creating a new sheet with the sheet name each month. The idea is to have a text box and a command button,enter the month in the text box and click the button. A sheet for the month to create at end.
I'm adding a command button at run time using excels help code;
Worksheets(newWorksheetName). OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=325, Top:=24, Width:=50, Height:=20
I want to change the buttons properties including its caption etc.. I've tried using'
Worksheet(newWorksheetName).OLEObjects("CommandButton1").Caption = "Do"
But i get a run time error. Also, the add method doesn't specify what the button is called, any clues?
I have a Excel 2007 spreadsheet of part numbers and quantities sold. In the spreadsheet we have similar part numbers, but my sumif command is adding these together. the parts are :
0124225031
R124225031
My column of part numbers is formatted as text
My formula is this =SUMIF(Sheet1!H:H,A16,Sheet1!Q:Q) where H is the part number and Q is the quanity
I tried adding a format command in the sumif command, but it returned a 0. =SUMIF(Sheet1!H:H,format(A16,"0"),Sheet1!Q:Q)
better formula and why is excel adding different part numbers together?
I would like to make a userform where additional textboxes (and labels) can be added to the form by clicking a command button. Is this possible to do?
For example, a userform which has:
Contractor 1: (TextBox)
and underneath this have a command button which when clicked will add another text box e.g.
Contractor 2: (TextBox)
I'm new to vba so haven't got a clue how to go about making this userform or even if it is possible.
I have data coes that need to be converted, basically need to remove 1st and 12th digits, 12th digit only, or 11th digit. I have built spreadsheet with a mid sub formula to do all 3 separately, but cannot figure out how to combine the formula to do all three.
I am attaching the spreadsheet,
Following code doesn't work
Dim Value1 as String
Value1 = Substitute(Cells(4, "A"), "A", "", 1)
correct syntax to assign the result of substitute function in the Variable?
I have a formula who examines if they are the same. The last number at first quote is not a problem (the 45). The problem occurs only and allways when the horse's name have an apostrophe " ' ". In first example apostrophe is different from the usual. If i manually delay it and replace it - type keyboards apostrophe everything works fine. Obviusly its a symbol. I want a small macro for replacing all these symbols at, lets say column B ,where these names are located. How can i use substitute at this case?
I understand that Microsoft left Filesearch out of VBA for Office 2007 because it was buggy. Sadly, however, I still need it. It would help if they placed a comment in VBA help that stated that it was discontinued. As it is, they make it look as if Filesearch is still available for use. OK, I'll stop ranting now.
After reading several earlier posts, apparently I have to use the Dir function. I learn visually and cannot figure out how to use the function from the VBA help file since there are no examples. Does anyone have an example of code using the Dir function to insert filenames in an array? Once I see the code, I'm sure I can adapt it to suit my needs.
I have a whole bunch of dates in a column that look like this:
5/01/1998 when it is supposed to be 5/01/2098 is there a character you can use when you are using the find & replace mode i.e.
*/**/20** I know it is not the asterisk but I believe there is some other character that can be used and it won't change any other of the numbers except the 19. I tried reformating and it does'nt work because of the way they sent it to me.
Is there a way to use something like the SUBSTITUTE function when sending an e-mail using a macro?
Here's my ....
Is it possible that when you press a command button, that the first thing it does is to execute the code assigned to another command button (IE in another sub).
View 9 Replies View RelatedI've got a workbook with multiple formulas e.g.:
t=S/D
TCh=Ch*(S^2/2D)*(D/Q)
TC=Co*(D/Q)+Ch*((i-D)/2i)*Q
which are built by implementing the symbols:
t, S, D, TCh, Ch, Q, TC, Co, i
I'd like to substitute the symbols in following sequence:
t = a
S = b
D = c
TCh = d
Ch = e
Q = f
TC = g
Co = h
i = x
Questions:
1) Which formula could substitute the symbols automaticly?
2) If there are up to 100 formulas in the workbook in the range of A1:E100,-
would it be possible to to set the substitution for the mentioned range?
See the attachment.
I would like to take a string such as R0-H6-D2 and return a number (1-4) based on one of four values for R, H and D in a separate column for each. The attachment should make what I am trying to do clearer.
Substitute.png
I have a text field (description) and in the description i have a product code S followed by 7 digits and then in the process of pasting into excel i have lost the space after this code and before the next text. E.g. "Ballpoint pen S1234567With Free Delivery" should be "Ballpoint pen S1234567 With Free Delivery".
I dont know how to say =if("S" followed by 7 numbers,subsitute ..... etc)
I understand how to use IF and substitute. its the 7 numbers part i am stuck on.
I could do it in access with the wildcards but excel is different.
I have numeric values in approx 1000 cell entries that I need to edit:
example cell C1 contains the value 00100300308W400
I'm trying to edit this entry to show 00/10-03-003-08W4/0.
I've tried using wildcards with the SUBSTITUTE function:
=SUBSTITUTE(C1,"***************","**/**-**-***-****/*")
I can choose among three variables in cell A1. They are named P10, P50 and P90. I want to substitute them with 1,2 and 3 in cell B1. Is it possible to do this by using the substitute-function or do I have to use a nested IF.
View 2 Replies View RelatedIs this possible because when i try to use the Substitute formula my Concatenate formula is doesn't work. This data in cell A1 is linked from another sheet
PHONE
WIRE
CANDY
INDIA
When I use the Concatenate formula only, it works fine but when i try to add the Substitute to this, it looks like this
PHONE WIRE CANDY INDIA
I want it to look like this, removing any blank lines within cell A1
PHONE
WIRE
CANDY
INDIA
Something wrong with the formula? how come it doesn't do both?
=SUBSTITUTE(CONCATENATE(A1),CHAR(10),"")
if i obtain an eqn by plotting a graph in excel, etc,
y = 1.22952117E-06x3 - 1.08197863E-05x2 + 9.97531712E-01x + 3.99014495E-01
and i wish to subsitube a cell value from another sheet into the 'x' in the above eqn and i need to do this 20 times.
MY DATA
LIST1 "long" strings
LIST2 strings with characters from LIST1: the order may differ
NEEDED
the expected result is the "substraction"
all characters form LIST1 which are NOT in LIST2 should appear in LIST3
COMMENT
to make it easier to read, I have put the same string in entire LIST1
EXAMPLE
LIST1LIST2LIST3ABCDABCDABCDBCADABCDCBADABCDACBDABCDADBCABCDABCDABCDADCA
I've got a small problem using VLOOKUP. If the function does not find a value, it returns #N/A. I would like it to say "Not Installed" instead.
The same goes for when VLOOKUP returns a zero - I would like it to return "Installed" instead. Since I've got a great number of rows, I would need an efficent way to change this.
I m using SUBSTITUTE function to replace commas with fullstop so I can multiply the end result with a number. But when I try to multiple for example B2 (0.1831) with 5, i get the VALUE! error.
Value Real Value (after substitute function)
0,1831 0.1831
23,3333 23.3333
12,5199 12.5199
5,5000 5.5000
20,5999 20.5999
24,4671 24.4671
200,0000200.0000
2,5386 2.5386
0,4000 0.4000
1,5019 1.5019
how I can resolve this so I can use the real values for computations (eg Real value *5), without having the VALUE! error message.