[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] SOMME.SI (SUMIF in English) [closed]

This function takes the Value in Sheet “Feuil2”, Cell A3 and compares that to the values in sheet “SUIVI STABILITE”, cells from D4 to AL4. It then adds all of the values in sheet “SUIVI STABILITE”, cells from D24 to AL24 that are in the same columns as the matches from the first 2 conditions. … Read more

[Solved] Matlab/Excel/R: Transforming an unbalanced dataset depending on value of column [closed]

A solution in Matlab: A = [1 5; 1 5; 1 6; 2 4; 2 2; 3 8; 3 4]; nMaxDays = max(A(:, 1)); nMaxSamples = max(accumarray(A(:, 1), 1)); mnSamplesMatrix = nan(nMaxSamples, nMaxDays); for (nDay = unique(A(:, 1))’) vnThisDay = A(A(:, 1) == nDay, 2); mnSamplesMatrix(1:numel(vnThisDay), nDay) = vnThisDay; end 0 solved Matlab/Excel/R: Transforming an … 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] Extract gz and convert csv to xlsx

While I agree the OP does not appear to have done their fair share of figuring this out (how hard is Google?), I know someone else will be looking in the future. Posting information will help them. @OP, I’m not going to do all your file handling work for you but here is the basic … 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