For Each Command Not Applying To Other Worksheets
Jul 8, 2013
My issue is my For Each command is not grabbing the next worksheet and applying my code. Here is my code:
Sub Test()
Dim ws As Worksheet
Worksheets("Report").Activate
For Each ws In ActiveWorkbook.Worksheets
With ActiveSheet.PageSetup
.LeftFooter = "&D"
.CenterFooter = "Test"
.RightFooter = "&P"
End With
Next
End Sub
View 5 Replies
ADVERTISEMENT
Jul 9, 2008
I've a command button on one worksheet (named "Front") that when clicked it "resets" a large number of cells back to "."
I've ALSO a command button on another worksheet (named "Back") that when clicked it also "resets" a large number of cells back to "."
Both are embedded on their own VBA tabs.
Both work exactly as needed.
No problem.
Is there a way I can move the coding from both to the "This Workbook" VBA tab, leave the one command button on the "Front" worksheet, and eliminate the one on the back?
I'm kinda guessing that this will require my rewording the
"(Range("C5").Formula = ".")"
(example line of code for the first cell it resets on the "front" tab) to something specifically referencing the "Front" worksheet, and the same for the ones on the "Back", but I could be wrong.
View 9 Replies
View Related
Nov 5, 2009
Why code will not hide command buttons or worksheets based on a given password. I have attached the code so.
Private Sub Workbook_Open()
Dim strUser As String, strPassword As String
strUser = InputBox("Enter User Name")
strPassword = InputBox("Enter Password")
Select Case strUser
Case "O"
If strUserPassord = "O4" Then
ActiveWorkbook.Sheets("Main").Select
O.Enabled = True
GOODBYE.Enabled = True
S.Enabled = False
R.Enabled = False
A1.Enabled = False
A3.Enabled = False
A4.Enabled = False
Sheets("Set4").Visible = True
Sheets("Set5").Visible = False
Sheets("Set61").Visible = False
Sheets("Set63").Visible = False................
View 9 Replies
View Related
Dec 5, 2012
I have an excel that has Marco being run by using a command button to create my pdf's. But my work sheets are Protected by a password. Is there a code for me to insert in order for the worksheet become unprotected for it to do the commands I am requesting?
View 5 Replies
View Related
Jul 23, 2014
I have a large data file with several different worksheets. In one cell I have a large set of individual numbers (i.e in the cell there is "123456 234234 939829") This value is my 'sample' number. The same sample could be in multiple rows on one sheet and could also be on other sheets. I am trying to find the sample in a column (on some sheets its column "Q", other sheets it could be different columns, but that column is fixed per sheet) and then copy the information on the same row in columns A & B and copy it to my target sheet. Then the next place the sample appears copy that info to the next row of my target sheet. So far I am stuck getting it to find the multiple values on one sheet. My code is below.
Code:
Sub Samplesearch()
Dim sample As String
Dim x As Integer
Dim y As Integer
Dim lr As Long
Dim lsr As Long
[Code]....
View 5 Replies
View Related
May 24, 2006
I am trying to create a program to automate the gauging figures on oil barges, currently everything is done by hand and takes approximately 20 minutes to complete. I have the charts entered for the tanks already and have the code set so that when you click on a tank "gauge" it will enter the "volume" which corresponds to that gauge on a totals sheet. Here is where my problem is coming in
The barges are gauged at four points
"before loading"
"after loading"
"before discharge"
"after discharge"
I want to set a worksheet as the default page with four command buttons that let the user select which operation he wants to perform. before load figures. after load figures and depending on which operation they select have it enter the volumes in the appropriate cells on the totals sheet. So if someone selects "loadopen" command button I want the following code to run on my worksheets............................
View 2 Replies
View Related
Aug 11, 2009
I am having trouble creating a macro for an excel file I am working on. I do not have much experience writing macros, so I apologize for any confusion. I have created a simplified version of the file I am attempting to write a macro for and attached it to my post here.
At this point it would be helpful for you to open up the attached file so that you can understand my explanation.
Basically what I want the macro to do is:
1. Match up "Product" on Wksht(Input) with "Product" on Wksht(Data).
2. Copy the "Usage per ton" and "Dollars per ton" values corresponding to the given product from Wksht(Input) to Wksht(Data) for the correct month. (The user will manually enter the month, ie "August 09" into Wksht(Input) each month when he runs the macro.)
++The color fills will not exist on my finished macro. I only put them there to illustrate the values that will be copied and pasted.
I want the macro to be written with Loop commands so that it will check to be sure the product number matches with the given location for pasting the data values. I should also note I use PasteSpecial_Values because of the formulas in the cells on Wksht(Input).
View 12 Replies
View Related
Apr 14, 2009
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 Related
Apr 19, 2014
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..
View 4 Replies
View Related
Jun 20, 2013
Excel 2007
I have this simple formula: =IF(SEARCH("ABC",BQ239,1)>0,"Found", "Not Found")
Instead of saying Not Found when the value is not in the cell BQ239 text string I get #VALUE! returned
how do I get it to say "Not Found"? I searching for a substring that can be anywhere in the string.
View 2 Replies
View Related
Jun 17, 2008
I have a table of data with names across the top and number of weeks down the left. The table lists amounts of money those names earned during the respective weeks. It looks something like this:
Mike Dan Bill Carl
400 500 600 700
800 900 1000 800
700 600 500 400
In a seperate worksheet within the same workbook, I have 3 columns of data. The first column is a name. The second column is a criteria. In the third column, I am trying to look up the value of 8 specified weeks of earnings of the name I put in column 1 and multiply those earnings by a percentage based on the criteria in column 2. Then sum the products.
I have a table of the 8 percentages I am trying to apply. There are 7 different percentage applications.
So if I am looking up Mike's earnings during those 8 specified weeks and the criteria in column 2 is "B", then I want to apply the appropriate column of percentages to those 8 looked up earnings, Multply them and then Add them.
Up until now, I have been trying to use some hybrid of HLOOKUP, SUMPRODUCT, and IF.
View 9 Replies
View Related
Jan 9, 2014
I am trying to update a project tracking sheet at work and I am having trouble. I have a list of construction projects (approx 130) along with details on the project, one detail being % completed. I am trying to create a summary of the projects at the bottom of the page, showing the total value of all projects, according to the % completed.
<10% is ANTICIPATED
= 10% is AWARDED
>10% <90% is IN PROGRESS
>90% is COMPLETED
[code]....
View 8 Replies
View Related
May 18, 2009
To explain I have two sets of merged data. On one fixed column I have two different sets of peoples age
1 - by age grouip eg 25 - 34
2 - By birth year so 01/02/1983
I know that person who is born between 1975 and 1984 would fall into the age group 25 - 34
I want to convert all the birth years into age groups. Its a lot of data (30,000 rows +) in random order
Does anyone have any idea how I would set this up, as I really want to add "age group" to a pivot table I have.
View 6 Replies
View Related
Feb 25, 2013
Using VBA in a code. I was using this same code for another workbook before and it worked fine.
[Code] ...
The filter works, but it is not applied. after the macro is run, I need to click "OK" on the filter for it to apply.
View 7 Replies
View Related
Feb 20, 2012
I have an excel sheet where I do a simple price-discount calculation for a product. Please check the file at:
Code: [URL] ........
A2 shows the price, B2 shows the discount and C1-L1 shows the number of units sold. C2-L2 is where I want to calculate the earnings based on the formula I have in C2. I want to apply the same formula to the entire row so that I can quickly see the earning for any number of units sold.
View 3 Replies
View Related
Feb 8, 2014
So right now I have a formula that I'm using in column "C":
=IF(B4="","",IF(AND(B4=22),"IN RANGE","OUT OF RANGE"))
So basically column C tells you if the number in the B column in within the range of 22-30. Now I want to write the formula in column D and make it apply to columns B and C.
So cells in columns B and C will have a number value in it and I will make column D where the formula is. There will be a number in B or C, but never at the same time. I can't figure out how to alter the formula to do this.
View 3 Replies
View Related
Mar 3, 2008
I use the If - Then statement in VBA to determine a condition which works perfectly fine for the particular cell I reference to, but i need it to apply to all the cells i.e. cells A1:A10?
Sub MACRO1()
If Range("A1") = "PAYE" Then
Range("B1").Formula = "=C2 * .128"
End If
If Range("A1") = "LTD" Then
Range("B1").Formula = "=(C2 - 100)* .128"
End If
End Sub
Sam
View 9 Replies
View Related
Aug 22, 2009
have a code for restricting printing until some cells are filled; however the code is been applied to all the file. I need to apply it to one one sheet.
Thanks for your help.....
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
If Application.WorksheetFunction.CountA(.Range("A11:K11"), ("A13:K13"), ("A16:K16"), ("A19:I19"), ("J18:K18"), ("A22:K22"), ("A25:K25"), ("B63:B64")) < 8 Then
MsgBox "Please Complete Information"
Cancel = True
Else
'Allow printing
End If
End With
End Sub
View 9 Replies
View Related
May 3, 2006
I have cell A7 Merged and need info in that cell. Example of what I want: Say I click on cell A1 and it is the color Pink, but has the letters blue in it. I would like it to display the word "Pink" in cell A7 not the number. Well I would like when you click on any cell with colors, that it will display the color in Cell A7. When I try different ways all it gives me is the number in the last cell of the square not the color and when I click on other cells it will not give me that cells info.
Private Sub CommandButton1_Click()
Dim x, rng As Range, r As Range
Dim myList
Dim row1 As Integer
x = Application.InputBox("Enter size of square: 2=2 by 2, 3=3 by 3, or 4=4 by 4", Type:=1)
Set rng = Range("a1").Resize(x, x)
myList = [{1,2,3,4,5,6,7,8;6,11,3,10,13,16,38,53;"Brown","Pink","Grey","Purple","Green","Red","Blue","Yellow"}]
rng. CurrentRegion.Clear
Randomize
For Each r In rng
x = Int((8 * Rnd) + 1)
With Application.WorksheetFunction
r.Interior.ColorIndex = .HLookup(x, myList, 2, False)
r.Value = .HLookup(x, myList, 3, False)
Range("A7").Value = r.Interior.ColorIndex
End With
Next
With rng
.ColumnWidth = 10
.RowHeight = 50
With .Font
.Size = 14
.Color = vbWhite
.Bold = False
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Borders.Weight = xlThick
End With
End Sub
View 9 Replies
View Related
Jun 14, 2007
I need to cut off addresses by 30 characters. I am doing this using the MID function. However, being a newb, how can I apply this function to say D4, D5 all the way to D899, without copy and pasting for 800 times? I did search this first, and couldn't find a resolution.
View 4 Replies
View Related
Feb 14, 2013
Cell B1 is to display money value dependent on what item has been selected from drop down box in Cell A1
View 2 Replies
View Related
Aug 21, 2013
Excel.xlsx
Attached is the example of the data, I am trying to sum the amount applying 2 criteria, within a particular month and other category. The formula tried is
=SUMIFS(D5:D10,C5:C10,"*June",E5:E10,H1)
However it is giving a value of zero only. I have tried other combinations as well.
View 4 Replies
View Related
Jun 8, 2014
I want to apply a simple formula to a number of cells in an existing workbook that already contain values E.g.
My column contains the values
5200
1600
4376
in separate cells
I want to divide each value by 1.2 - without having to change every individual cell - can it be done?
View 2 Replies
View Related
Apr 3, 2014
I have a macro which sorts data within a cell. This is working perfectly fine but the only problem with this is that it works only for a single which is selected. How can I apply this macro to range of cells I select using a mouse.
View 3 Replies
View Related
Feb 6, 2009
For simplicity, let's assume I have three columns, "Company," "Policy," and "Balance."
Example:
Company A Life $1
Company A Med $2
Company A Dent $3
Company A Disab $4
Company B Life $9
Company B Med $5
Company B Dent $7
Company B Disab $2
According to my post preview, the columns are running together, but I do have it arranged in three distinct columns. What I want to do is program a macro to do the following:
Every time the name of the company changes, I want Excel to insert two rows after the last of the group, and have a summation of the "Balance" column in the first inserted row.
This is what it should look like:
Company A Life $1
Company A Med $2
Company A Dent $3
Company A Disab $4
$10 <- (this should be directly under the $4, but I'm not good with forum languages)
Company B Life $9
Company B Med $5
Company B Dent $7
Company B Disab $2
$23 <- (same with this - should be directly under the $4)
View 3 Replies
View Related
Jan 9, 2009
I have a long column of numbers that I want to apply a single percentage to all the numbers in each column. How do I do that?
View 3 Replies
View Related
Dec 2, 2011
In Excel we can apply different formatting styles to the "TEXT" contents of a cell while we are in edit mode. For example we can apply "BOLD" to Brown Fox and "UNDERLINE" to lazy in a string "A quick brown fox jump over a lazy dog.
But when the above string is concatenated from the contents of various cells, excel is unable to apply different formatting (as exampled above) in the concatenated cell. Although we can apply bold, underline etc by selecting the concatenated cell but it is applied to whole string and not to the selected parts of string.
Sheet1 *A1Brown2Fox3Lazy4*5A quick Brown Fox jump over a Lazy DogSpreadsheet FormulasCellFormulaA5="A quick "&A1&" "&A2&" jump over a "&A3&" Dog"
Moreover, MS Word's "mail merge" is capable to apply different formatting to different "Fields" in a single paragraph.
Is there any way so we can apply multiple formatting to the contents of a single cell which is not "Text" but result of "concatenate" in Excel, like MS Word's mail merge or as it is applied in custom format within straight brackets like [Red] etc.
View 3 Replies
View Related
Sep 19, 2013
I am using two separate workbooks. I am tranferring dates into a new spreadsheet to track projects dates for milestones.
The formula I am using is this: =IF('[BBBBB Dates as of 9-9-13.xlsx]Sheet1'!$CQ$4="", VLOOKUP(W54, '[BBBBB Dates as of 9-9-13.xlsx]Sheet1'!$1:$1048576, 94, FALSE), VLOOKUP(W54, '[BBBBB Dates as of 9-9-13.xlsx]Sheet1'!$1:$1048576, 95, FALSE)).
I would like the cell to turn green if the last part of the formula is true and stay clear if the first part of the formula is true.
I also need to add color beyond just that. I was attempting to apply conditional formatting but am a bit stumped. I want the green to be maintained regardless of other formatting. I would also like to apply to cells that are not color coded green:
Red - if the date is overdue
Yellow - if the date is within 7 days
Otherwise, leave the cell color as clear
Is this possible with conditional formatting? I am not at all proficient in VBA...
View 9 Replies
View Related
Sep 21, 2013
I want to have a condition which will check if the value in cell is present or not and based on that i have to display result in a cell.
Eg: In Sheet1, in column D i have 4 values (Simple, Complex, Medium Complex, Very Complex)
In Sheet 4, we have numeric values to Simple, complex...Like below
Complexity Estimation
Simple 2hrs
Complex 4hrs
Medium Complex 2.5hrs
Very Complex 6hrs
In Sheet5, we have values defined in % like below:
Requirement Analysis
15%
Design
20%
Coding
20%
System Testing
15%
[code]....
In column G of Sheet1, we have to write a function or formula which we do below calculation.
IF (Sheet1!D3="Simple") then Sheet1!G3=Sheet5!B2(ie.15%) of Sheet4
Similarly i will have Sheet1!D3 values as Complex,Medium Complex,Very complex
View 2 Replies
View Related
Aug 20, 2007
There is currently data on each sheet in my workbook. I am trying to get a macro to Copy the formatting of sheet "Statement" and paste the formatting on all other sheets in the workbook, except Sheet.actual
There is also a picture @ the top of sheet statement, that i would like copied and pasted to each sheet except sheet.actual.
Also, on all sheets except for STATEMENT & ACUTAL, i need the formula in cell C11 =vlookup(F14,cardnum,2,false) and in cell A11 = Name :
View 9 Replies
View Related