Using the same principal and display format of the VBA code below, Please create another…
- User
Using the same principal and display format of the VBA code below, Please create another 'Sub InfoByProvider' with the following criteria: ThisWorkbook.Worksheets("ADMIN RESULTS").Range("A7:K300").ClearContents Set adminResults = ThisWorkbook.Sheets("ADMIN RESULTS") pasteRow = 7 Find the worksheet with the name displayed in K1 and copy the values only of column B to J from row 6 to 30 using the principal of the vba below.
Sub AllServicesResults() ThisWorkbook.Worksheets("ADMIN RESULTS").Unprotect Password:="edit" Application.EnableEvents = False Dim ws As Worksheet Dim adminResults As Worksheet Dim lastRow As Long Dim i As Long Dim pasteRow As Long ThisWorkbook.Worksheets("ADMIN RESULTS").Range("A7:K300").ClearContents Set adminResults = ThisWorkbook.Sheets("ADMIN RESULTS") pasteRow = 7 For Each ws In ThisWorkbook.Worksheets If Len(ws.Name) = 3 Then lastRow = ws.Cells(ws.Rows.count, "B").End(xlUp).row For i = 6 To lastRow If ws.Cells(i, "B").Value = "Service" Then adminResults.Cells(pasteRow, 1).Value = ws.Cells(1, "B").Value adminResults.Cells(pasteRow, 2).Value = ws.Cells(i, "B").Value adminResults.Cells(pasteRow, 3).Value = ws.Cells(i, "C").Value adminResults.Cells(pasteRow, 4).Value = ws.Cells(i, "D").Value adminResults.Cells(pasteRow, 5).Value = ws.Cells(i, "E").Value adminResults.Cells(pasteRow, 6).Value = ws.Cells(i, "F").Value adminResults.Cells(pasteRow, 7).Value = ws.Cells(i, "G").Value adminResults.Cells(pasteRow, 8).Value = ws.Cells(i, "H").Value adminResults.Cells(pasteRow, 9).Value = ws.Cells(i, "I").Value adminResults.Cells(pasteRow, 10).Value = ws.Cells(i, "J").Value adminResults.Cells(pasteRow, 11).Value = ws.Cells(1, "J").Value pasteRow = pasteRow + 1 End If Next i End If Next ws ThisWorkbook.Worksheets("ADMIN RESULTS").Range("J5").Value = "ALL SERVICES CURRENTLY DUE" Application.EnableEvents = True ThisWorkbook.Worksheets("ADMIN RESULTS").Protect Password:="edit" End Sub
- Assistant
Sub InfoByProvider() ThisWorkbook.Worksheets("ADMIN RESULTS").Range("A7:K300").ClearContents Set adminResults = ThisWorkbook.Sheets("ADMIN RESULTS") pasteRow = 7
codeDim ws As Worksheet Dim lastRow As Long Dim i As Long Dim providerName As String providerName = adminResults.Range("K1").Value For Each ws In ThisWorkbook.Worksheets If ws.Name = providerName Then lastRow = 30 For i = 6 To lastRow adminResults.Range("B" & pasteRow & ":J" & pasteRow).Value = ws.Range("B" & i & ":J" & i).Value pasteRow = pasteRow + 1 Next i End If Next wsEnd Sub
- User
- Assistant
Sub InfoByProvider() ThisWorkbook.Worksheets("ADMIN RESULTS").Unprotect Password:="edit" Application.EnableEvents = False ThisWorkbook.Worksheets("ADMIN RESULTS").Range("A7:K300").ClearContents
code - User
Please write me a VBA change event that does the following If the value in F1 changes calculate the formula in K1
- Assistant
You can add the following VBA code to the sheet module where you want the change event to occur (e.g., "Sheet1" module in the VBA editor):
vbaPrivate Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Me.Range("F1")) Is Nothing Then Me.Range("K1").Formula = Me.Range("K1").Value ' Calculate the formula in K1 End If End SubThis code will trigger the recalculation of the formula in cell K1 whenever the value in cell F1 is changed.