[Solved] Open specific sheet according to current Date [closed]

Something like this might work in the ThisWorkbook module’s, Workbook_Open event. Private Sub Workbook_Open() Dim ws As Worksheet Dim mnth As String, dte As String, mday As String mday = Now() – Weekday(Now(), 3) mnth = Month(mday) dte = Day(mday) tabstr = mnth & “-” & dte For Each ws In Worksheets If ws.Name = … Read more

[Solved] using instr to find values in vba

You can try this: Sub find() Dim x As String, i As Long, lastrow As Long, y As Long Dim sh1 As Worksheet, sh2 As Worksheet Set sh1 = Sheets(“Sheet1”): Set sh2 = Sheets(“Sheet2”) x = “ra01” With sh1 lastrow = .Range(“F” & .Rows.Count).End(xlUp).Row For i = 2 To lastrow If InStr(.Range(“F” & i).Value, x) … Read more

[Solved] Excel button that writes down the time of clicking

Create a new module in your VBE and stick this in there: Sub capturetime() Dim timeWS As Worksheet Dim timeRange As Range ‘Change “Sheet3” to whatever worksheet is your click log Set timeWS = ThisWorkbook.Sheets(“Sheet3”) ‘find the last cell in column A of your log Set timeRange = timeWS.Range(“A” & timeWS.Rows.Count).End(xlUp).Offset(1) ‘Write which button was … Read more

[Solved] Cell Value Increment and Offset

Try using Public Variable like this: Public n As Long ‘~~> Declare a public variable at the top of the module Then in your sub try something like this: With Sheets(“Sheet1”).Range(“A6”).Offset(n, 0) ‘~~> change to suit If n = 0 Then .Value = 1 Else .Value = .Parent.Range(.Address).Offset(-1, 0) + 1 End If n = … Read more

[Solved] Isolate a non duplicate of a chain separated by “,” from another longer chain in VBA [closed]

This function will work for you Function ReturnUnique(cell1 As Range, cell2 As Range) As String ReturnUnique = “” Dim v1 As Variant, v2 As Variant v1 = Split(cell1.Value, “,”) v2 = Split(cell2.Value, “,”) Dim i As Long, j As Long Dim bool As Boolean For i = LBound(v1, 1) To UBound(v1, 1) bool = True … Read more

[Solved] VBA Dictionary for uniqueness count

This should give the basic idea – Use the item you want to count as the key, and the count itself as the value. If it is already in the Dictionary, increment it. If not, add it: Const TEST_DATA = “Apple,Orange,Banana,Banana,Orange,Pear” Sub Example() Dim counter As New Scripting.Dictionary Dim testData() As String testData = Split(TEST_DATA, … Read more