Re: Round Up to certain decimal place, end in 5 or 9
There is probably a slicker formula, but this works
=CEILING(A1+1, 5)-(0=MOD(CEILING(A1+1, 5),10))
Re: Round Up to certain decimal place, end in 5 or 9
There is probably a slicker formula, but this works
=CEILING(A1+1, 5)-(0=MOD(CEILING(A1+1, 5),10))
Re: Populate UserForm text boxes with cell values from active row
I would do this a little differently
Clear that code out of the Intialize event.
Then put this code in the sheet code for the sheet in question.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
UserForm1.TextBox1.Text = Target.EntireRow.Range("B1").Text
End Sub
Note that the Userform will be Loaded (and the Intialize event run), but not Shown, the first time that the Selection is changed on that sheet.
Re: Inventory list with multiple columns
I don't understand what your desired result is.
Could you add the desired result to your attached file?
Re: excel vba multipage userform
In the attiched file, Userform2 has no multi-page control.
Userform3 has a MultiPage control with 19 pages. Many of which are not visible, many of which are disabled
You can make those pages visible (or invisible) by setting the .Visible property of the page.
Example
To look for a particular employee's page, you could use code like
Re: Vba to highlight the cell and remove duplicates
Try this
Sub test()
Dim LastRow As Long
Dim MatchRow As Variant
Dim i As Long
With Sheet1.Range("C:C")
.Interior.ColorIndex = xlNone
For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 3 Step -1
MatchRow = Application.Match(.Cells(i, 1).Value, .Cells, 0)
If MatchRow <> i Then
.Cells(i, 1).Interior.Color = vbRed
.Cells(i, 7).NoteText Text:="Old Value: " & .Cells(MatchRow, 10).Value
.Cells(i, 8).NoteText Text:="Old Value: " & .Cells(MatchRow, 11).Value
.Cells(i, 10).NoteText Text:="Old Value: " & .Cells(MatchRow, 13).Value
.Cells(MatchRow, 1).EntireRow.Delete shift:=xlUp
End If
Next i
End With
End Sub
Display More
Re: Extract number before specific text
This formula should do that.
=TRIM(RIGHT(SUBSTITUTE(LEFT(SUBSTITUTE(A1, "(fail-fail", REPT(" ", 255)), 255), "-", REPT(" ", 255)), 255))+0
Re: Name sheet after a cell that changes
If you are on a Mac, you are probably using 2011. But putting this in the sheet's code module will work. (If the cell has a formula, it would be slightly different)
Note that it rejects the user entering an illegal sheet name
Re: Generate Unique ID
If column A has a list of all the ID numbers in use, the next number in the AAA sequence would be ="AAA" & TEXT(COUNTIF(A:A, "AAA" & "*"), "000")
if the string AAA were in B1, that would become
=B1 & TEXT(COUNTIF(A:A, B1 & "*"), "000")
Re: How do I check an amount is divisible by a specified amount. Cash/Paying in slip
One alternate approach would be to use combo boxes rather than textBoxes
With code like this, the user can only enter multiples of 50, up to 500 in this case
Private Sub UserForm_Initialize()
Dim i As Long
With ComboBox1
.MatchEntry = fmMatchEntryComplete
.MatchRequired = True
.ShowDropButtonWhen = fmShowDropButtonWhenNever
For i = 0 To 500 Step 50
.AddItem i
Next i
End With
End Sub
Display More
Note that this code forbids the entry of 50.0
Re: Guide Line Required for Listbox
Your image shows a couple of inconstancies. In the listbox ID503 is No. 3, but on the sheet it is No. 2.
Also the user form has the date of Jan, but the desired location of the number of absences is Feb.
Could you attach a small workbook showing your lay-out etc.
One thing that I would think about is adding a hidden fourth column to the listbox to store the address of the row from which the data comes.
Dim oneRow as Range
Dim j as Long
ListBox1.ColumnCount = 4
ListBox1.ColumnWidths = ";;;0"
With Range("A2:C10")
For Each oneRow in .Rows
ListBox1.AddItem oneRow.Cells(1,1)
ListBox1.List(ListBox1.ListCount - 1, 1) = oneRow.Cells(1, 2)
ListBox1.List(ListBox1.ListCount - 1, 2) = oneRow.Cells(1, 3)
ListBox1.List(ListBox1.ListCount - 1, 3) = oneRow.Address(,,,True)
Next oneRow
End With
Display More
Re: Named Cells - Relative References for Dynamic Naming
Have you looked at the INDIRECT function?
Re: finding cell by ref
It sounds like you have a given of 7, 8, 9, 6, 5.
What do you want returned? The string "NAME1" or the location of that cell or something else?
Where are the inputs 7, 8, 9, 6, 5 given?
Will the search terms always be in columns F:J?
Does the order matter, i.e. do you want the same thing returned from the input 8, 7 ,9, 6 , 5?
Re: Excel checkbox to change value of a cell
You could put code like this in the sheet's code module.
No checkboxes are needed. Just double click on the cell in column C and it will check/uncheck. And make the changes that you desire.
' in sheet's code module
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Rem Marlett checkbox code
With Target
If .Column = 3 And 1 < .Row And .Row <= Range("B65536").End(xlUp).Row Then
Cancel = True
If IsNumeric(.Offset(0, -1).Value) Then
If .Value = vbNullString Then
.Font.Name = "Marlett"
.Font.Size = 14
.Value = "a"
.Offset(0, -1).NumberFormat = "$#,##0.00 ""paid"""
Else
.Value = vbNullString
.Offset(0, -1).NumberFormat = "$#,##0.00"
End If
.Offset(0, -1).Select
End If
End If
End With
End Sub
Display More
Note that the value in column B is unchanged, it is still the amount entered, what has altered is the number format of column B. To sum all the Paid values a formula like =SUMIF(C:C, "a", B:B) will return the sum of all the paid values.
Re: Calendar Form Control - Only allow weekdays to be selected
Yes its quite possible.
Change the posted code so the Enabled property is true only if the Weekday of the Calendar.Value is vbThursday.
Re: Target by Change
What is the formula in AC3? Are all the precedents on the same worksheet?
Re: reference a tiered price table to get $ based on quantity
You can do this simply with a VLOOKUP chart. with a formula like =VLOOKUP(G10,B11:C14,2)
0 $17.58
30 $14.06
100 $11.25
500 $9.00
note that the entries in B10:B14 don't have text in them, just numbers
Re: Trying to create crawler
Excel is not a web browser by any means, so it wouldn't be an appropriate platform for your crawler.
And this file that you found, board rules forbid conversations about how to defeat security including Locked VBA Project.
Re: How to filter through multiple “Arrays” at once?
Let me see if I understand your variable names.
List1 is your customers from last year. They are found in column A, starting at row 4
List2 is your customers from this year. They are found in column B, starting at row 4. (these lists may have different lengths)
these are your input
Your output is
List3 those customers who bought in either of the two years. (i.e.the union of List1 and List2)
List4 is those customers who bought last year, but not this year (i.e. List1 less any entries in List2)
List5 is those customers who bought this year, but not last year (List2 with any List1 entries removed)
Its not clear where you want those lists to be put, but my code will put them in columns C, D and E respectively.
You aren't asking for a list of customers who bought in both years. But this code has an arrBothYears that handles that case (it can be removed) and places those entries in column F.
Once in the sheet, the output is then sorted.
Sub test()
Dim List1 As Variant, List2 As Variant, List3() As String, List4() As String, List5() As String
Dim Size1 As Long, Size2 As Long
Dim Pointer3 As Long, Pointer4 As Long, Pointer5 As Long
Dim i As Long
Dim arrBothYears() As String, PointerBoth As Long
Rem get input data
With Range("A:A")
List1 = Range(.Cells(4, 1), .Cells(Rows.Count, 1).End(xlUp)).Value
End With
With Range("B:B")
List2 = Range(.Cells(4, 1), .Cells(Rows.Count, 1).End(xlUp)).Value
End With
Size1 = UBound(List1, 1)
Size2 = UBound(List2, 1)
Rem set maximum size for result arrays
ReDim List3(1 To Size1 + Size2, 1 To 1)
ReDim List4(1 To Size1, 1 To 1)
ReDim List5(1 To Size2, 1 To 1)
ReDim arrBothYears(1 To Size1 + Size2, 1 To 1)
For i = 1 To Size1
Rem put all of list1 into list3
Pointer3 = Pointer3 + 1
List3(Pointer3, 1) = List1(i, 1)
If IsNumeric(Application.Match(List1(i, 1), List2, 0)) Then
Rem if List1(i) is in list2, put it in arrBothYears
PointerBoth = PointerBoth + 1
arrBothYears(PointerBoth, 1) = List1(i, 1)
Else
Rem if list1(i) is not in list2, put it in list4
Pointer4 = Pointer4 + 1
List4(Pointer4, 1) = List1(i, 1)
End If
Next i
Rem at this point List4 and arrBothYears are done
For i = 1 To Size2
If IsError(Application.Match(List2(i, 1), List1, 0)) Then
Rem List2(i) is not in List1, therefore needs to be added to List3
Pointer3 = Pointer3 + 1
List3(Pointer3, 1) = List2(i, 1)
Rem also add it to list5
Pointer5 = Pointer5 + 1
List5(Pointer5, 1) = List2(i, 1)
End If
Next i
Rem all lists are completed
Rem write to sheet
Application.ScreenUpdating = False
With Range("C:C").Resize(Size1 + Size2, 1).Offset(3, 0)
.Value = List3
.Sort key1:=.Cells(1, 1), order1:=xlAscending, Header:=xlNo
End With
With Range("D:D").Resize(Size1, 1).Offset(3, 0)
.Value = List4
.Sort key1:=.Cells(1, 1), order1:=xlAscending, Header:=xlNo
End With
With Range("E:E").Resize(Size2, 1).Offset(3, 0)
.Value = List5
.Sort key1:=.Cells(1, 1), order1:=xlAscending, Header:=xlNo
End With
With Range("F:F").Resize(Size1 + Size2, 1).Offset(3, 0)
.Value = arrBothYears
.Sort key1:=.Cells(1, 1), order1:=xlAscending, Header:=xlNo
End With
End Sub
Display More