Re: Finding specific columns and counting in them
The SUMPRODUCT function can do this for you, or you can use the COUNTIF function; however without knowing the layout of your data, I can offer no specific solution.
Re: Finding specific columns and counting in them
The SUMPRODUCT function can do this for you, or you can use the COUNTIF function; however without knowing the layout of your data, I can offer no specific solution.
Re: Subtotal & Min Circuit Breaker
Try using a simple =SUM(G3:G8) in cell G9.
I am not sure why the subtotal formula didn't work though.
Re: cumulative production that stops once order qty is met
One approach is shown in the attached.
Re: InputMsgon/Off for ALL worksheets?
Try this
Sub InputMsgOn()
Dim ws As Worksheet
Dim rng As Range
Dim c As Range
For Each ws In ActiveWorkbook.Worksheets
On Error GoTo nocells
Set rng = ws.Cells.SpecialCells(xlCellTypeAllValidation)
For Each c In rng
On Error Resume Next
c.Validation.ShowInput = True
Next c
nocells:
On Error Resume Next
Next ws
End Sub
Sub InputMsgOff()
Dim ws As Worksheet
Dim rng As Range
Dim c As Range
For Each ws In ActiveWorkbook.Worksheets
On Error GoTo nocells
Set rng = ws.Cells.SpecialCells(xlCellTypeAllValidation)
For Each c In rng
On Error Resume Next
c.Validation.ShowInput = False
Next c
nocells:
On Error Resume Next
Next ws
End Sub
Display More
Re: Sorting multiple spreadsheets
HI,
ActiveWorkbook.Worksheets("10.19") refers to a specific worksheet.
You will have to repeat the sort for each worksheet or iterate through the Worksheets() collection (For each ws in Activeworkbook.worksheets...)
Re: Countif or if statement with ? wildcard
The attached shows one solution using Mid()
Re: Named Range using Indirect does not work when Evaluated in VBA
Try using this function in your VBA to calculate the range count.
Usage : FnCountTheValues(Range("D8:D500"))
Re: Using RangeName instead of hard coded time in TimeValue Vba Macro
in the immediate window, this worked for me
print range(activeworkbook.names("thetime")).Value
it returned a value of 5.78703703703704E-05
it did fail however if "00:00:05" was entered as a text string, ensure it is entered as a time value without the quotes.
Re: Insert and Delete Rows with formula and formating in a table using VBA
I am wondering why you are using VBA at all.
Select your data and press Crtl-T. This will create an excel table.
One of the proprieties of an excel table is that it will allow you to insert a row, and the formatting and formulas are inheritied on the new row.
Table heading integrity for the table is maintained too.
Give it a go, it looks like it will fit your needs.
Re: Using RangeName instead of hard coded time in TimeValue Vba Macro
Try playing wit the follwoing
range(activeworkbook.names("timevalue")).Value to retrieve the value of the cell referred to by the name "timevalue" on the active sheet
Re: Picking up a range in a formula
My mistake - I forgot to test properly.,
See the attached workbook with the adjusted lookup range.
Re: Creating a copy of a Worksheet for each Autofilters checked
An easy way to do this is to create a summary pivot table of your data.
One of the default behaviors of a pivot table is that when you double click a value in the pivot table, it will open up a new worksheet with the values that were used to create the summary entry.
http://www.mrexcel.com/archive/Pivot/ provides a good intro into pivot tables if you have not used them before.
Re: Picking up a range in a formula
Highlight the range H1 to H9 and enter the formula =OFFSET(A2,0,MATCH(G1,$A$1:$E$1,0),9,1) and the press Crtl-Shift-Enter (instead of just enter, to create an array formula) to populate the range H1:H9 with the matching results.
Re: getting the sum of filtered data without the use of formulas
Considered using the SUBTOTAL function?
It can be placed anywhere on the spreadsheet, is automatic, and faster than any custom function.
Or, if needed, it can be used as the basis for any VBA solution.
Re: VBA Find not working!
The following code is UNTESTED, but may help.
Dim sh As Worksheet
Dim iLoop As Integer
For iLoop = 7 To 1719
' this is where the invoices are in an excel sheet
iloopoffset = iLoop - 6
' as you see above, the list of invoices starts at line 7, so I used this to offset
If Range("K6").Offset(iloopoffset).Value = "No" Then
' Column K is the one saying if the invoice was found or not in the branches file
Set searchedvalue = Range("B6").Offset(iloopoffset, 0)
' I used this so i could use the value in the .find formula
MsgBox (searchedvalue.Value)
Workbooks.Open ("C:\Users\xxxxxx\Documents\xxxxxx\XML " + Range("D6").Offset(iloopoffset).Value)
For Each sh In Worksheets
'changed activesheet.name to sh.name
If sh.Name = "062015" Or "052015" Or "042015" Or "032015" Or "022015" Or "012015" Or "122014" Or "112014" Then
' I needed to do this because on the sheets with the names above, the searched value will be in another column. sheets before 112014 are different.
'Set NFE = Worksheets(sh.Name).Range("B:B").Find(Range("B6").Offset(iloopoffset, 0).Value, lookat:=xlPart)
' was using the worksheet find method - not the range find method.
With sh.Name.Range("B:B")
Set NFE = .Find(Range("B6").Offset(iloopoffset, 0).Value, LookIn:=xlValues, lookat:=xlPart)
If Not NFE Is Nothing Then
firstAddress = c.Address
Do
Set NFE = .FindNext(c)
Loop While Not NFE Is Nothing And c.Address <> firstAddress
End If
End With
Else
'Set NFE = Worksheets(sh.Name).Range("A:A").Find(Range("B6").Offset(iloopoffset, 0).Value, lookat:=xlPart)
' was using the worksheet find method - not the range find method.
With sh.Name.Range("A:A")
Set NFE = .Find(Range("B6").Offset(iloopoffset, 0).Value, LookIn:=xlValues, lookat:=xlPart)
If Not NFE Is Nothing Then
firstAddress = c.Address
Do
Set NFE = .FindNext(c)
Loop While Not NFE Is Nothing And c.Address <> firstAddress
End If
End With
End If
If Not NFE Is Nothing Then
'changed activesheet.name to sh.name
MsgBox ("Found on sheet " + sh.Name + " " + NFE.Address)
Range(NFE.Address).Offset(, 12).Value = "YES"
' yes for found
ActiveWorkbook.Save ' this is done outside the "For Each sh In Worksheets" loop - do you really want it here?
ActiveWindow.Close ' this is done outside the "For Each sh In Worksheets" loop - do you really want it here?
End If
Next sh
ActiveWorkbook.Save
ActiveWindow.Close
End If
Next iLoop
End Sub
Display More
Re: Conditional format using IF formula
Hi Lanky,
you say "7 different cells that can contain either a "O" "X" or "N/A"." - I cannot see any reference to the "X' in your formula.
If any of the referenced cells contain an "X", the result of the if statement will be "". Could this be why the formula isn't populating with the expected result?
Re: Autofilter Hide Column
Does the following help?
Function AutoFilter_Criteria(Header As Range) As String
'On Error GoTo em
Dim strCri1 As String, strCri2 As String
Application.Volatile
With Header.Parent.AutoFilter
With .Filters(Header.Column - .Range.Column + 1)
If Not .On Then Exit Function
strCri1 = .Criteria1
If .Operator = xlAnd Then
strCri2 = " AND " & .Criteria2
ElseIf .Operator = xlOr Then
strCri2 = " OR " & .Criteria2
End If
End With
End With
AutoFilter_Criteria = UCase(Header) & ": " & strCri1 & strCri2
Call rowcountnoblanks
End Function
Function rowcountnoblanks()
'Application. ScreenUpdating = False
'Range("A3").Select
Range("A3").Activate
Dim x As Object
Dim r As Integer, c As Integer
Set x = ActiveCell
r = x.Row
c = x.Column
r = 3
c = 1
Dim i As Integer
Dim totalrows As Integer
Dim flag As Boolean
flag = False
i = 1
Do Until flag = True
If Cells(r + i, c).Value = "" And Rows(r + i).EntireRow.Visible Then
flag = True
totalrows = totalrows + 1
Else
i = i + 1
End If
Loop
'Application.ScreenUpdating = True
MsgBox totalrows ' result for purchasing manager is 30 however it actually should be 13 -- it appears to be counting the results that are not present when the filters applied
End Function
Display More
Re: Filterable Dynamic Chart Range
The no calculation in the chart series seems to be the case. But I am not 100% sure.
You could however have the series refer to another named range that is the result of the calculation.
See this page for clarification.