Reddit » Visual Basic for Applications
159 FOLLOWERS
A place for questions and discussion on Visual Basic for Applications (VBA) and its integrated development environment (IDE).
Reddit » Visual Basic for Applications
8h ago
If I spell check a single cell:
ActiveSheet.Range("B18").CheckSpelling
It checks spelling and finds the error, then proceeds to check the whole sheet.
Advice I've found online says make it more than one cell to fix the bug. So I try:
ActiveSheet.Range("B18:C18").CheckSpelling
This code runs, and doesn't find errors on the rest of the page. BUT, it also doesn't find the error in B18. It doesn't seem to do anything.
So I just want some code that spell checks a single cell. Is there a solution?
submitted by /u/MilkyMilkerson
[visit reddit] [comments ..read more
Reddit » Visual Basic for Applications
8h ago
Hi. I have a UserForm that has multiple check boxes in a frame (fraFindWorker). I need to add some code to a button I have so that when you click it it checks that at least one checkbox in that frame is true.
I have tried copying someone elses code to this same thing but I am coming up with an error. Here is the code:
Private Sub cmdGo_Click() ' check that at least one checkbox is ticked. Dim oCtl As msforms.Control Dim iX As Integer For Each oCtl In frmFindWorker.Controls If TypeName(oCtl) = "CheckBox" And oCtl.Value = False Then iX = iX + 1 If iX > 0 Then MsgBox "Selection made" Exit Fo ..read more
Reddit » Visual Basic for Applications
14h ago
I have about 3000 excel files. They are saved in different folders in one master folder. Each file has multiple tabs. I want to write a programme to open this one tab in each of the excel files, copy and paste the file into another. What’s the right way to automate this? Is it VBA?
submitted by /u/Proper6ioq
[visit reddit] [comments ..read more
Reddit » Visual Basic for Applications
14h ago
I have a list of students and grades in sheet 1. The grades are added manually. In sheet 2, I have just a list of students which I copy as an xls from another program. Our student list changes, only ever adding. Student information is in Column A to Column E on both sheets. I want to copy only new student information from sheet 2 to sheet 1. I have the following script but it strangely removes some data from Column F in random rows:
Sub CopyRows()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Sheets("Sheet2").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPreviou ..read more
Reddit » Visual Basic for Applications
20h ago
I hope this is the right place to ask this question. I am planning to automate a process, that when cell A1 has a certain word, cell C2 will put in a formula for a vlookup. Below is my code. It keeps giving me a 1004 error.
``` Private Sub Worksheet_Change(ByVal Target As Range)
' Application.EnableEvents = False
If Me.Range("A1") = "Material" Then AddFormula End If
' Application.EnableEvents = True
End Sub
Sub AddFormula() Dim ws As Worksheet Set ws = Worksheets("Sheet1")
ERROR>> ws.Range("C2").FormulaLocal = "=VLOOKUP([@Material];'Product list_Finalized.xlsx'!Table1[[#All];[SKU ..read more
Reddit » Visual Basic for Applications
20h ago
Why havent the VBA community put together pieces of reusable code in one big repository?
I need to reinvent the wheel while doing basic stuff. Example: Want an array length? Since there is no function Len() or Length(MyArray), search SO and get confused with the top three solutions because considering the edge cases will get you to a 15 line piece of code.
Want to calculate on sparse matrices ? Good luck making one of those nice C libraries for scientific computation to talk to plain VBA in 2024. Nasty. Actually easier to bring Python to the project and send CSVs to Power Query.
Am I missing ..read more
Reddit » Visual Basic for Applications
1d ago
I don't know what is happening here. I'm trying to get it to work, but I haven't had any luck. Anyone able to help?? This is in Google Sheets.
Sub UpdateMonthlySummary()
Dim transactionsSheet As Worksheet Dim summarySheet As Worksheet Dim transactionsLastRow As Long Dim summaryLastRow As Long Dim transactionsRange As Range Dim summaryRange As Range Dim transactionsCell As Range Dim summaryCell As Range Dim transactionID As String ' Set the worksheets Set transactionsSheet = ThisWorkbook.Sheets("Transactions") Set summarySheet = ThisWorkbook.Sheets("Monthly Summary") ' Find the last row in Tr ..read more
Reddit » Visual Basic for Applications
1d ago
Hi, I have created a change log script that will record a change done on a cell. The logic is simple - when you select a cell it's value goes to a variable as a PreviousValue and when you change the value in a cell - new value is stored in ChangedCell and the event triggers a subroutine to add all necessary data to the log. It works ok when you change one cell at a time. But when you select a cell or range of cells and perform drag-copy it crash - sorry I don't know how this event is called when you copy on bottom right corner of the cell with black + maybe AutoFill? Any ideas how to solve th ..read more
Reddit » Visual Basic for Applications
2d ago
Hi! I am trying to create a macro to send an email with outlook. In this mail I am always copying and pasting a pivot table from my excel file, and I was wondering if it is possible to get automatically that pivot table in the body of the email once I run the macro. I have developed the macro to send the mail but I am missing the part of pasting the pivot table. Here is what I have by now:
Sub EMAIL_TEST()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ["test@testemail.com ..read more
Reddit » Visual Basic for Applications
2d ago
Excel formula using VBA macro that sends an email to the email address in column Q, when the date in column c is met. All information gathered is the same per row, each row is different and should operate the same. The name the email should be addressed to will be the information entered in column A, again each row different. Email should read, Good day 'column A information,' it is time to scheduled our annual assessment. Please email me back with your availability. Thanks and have a great day. Greg Dornbush Service Coordinator | UPMC Health Plan 200 Corporate Center Drive | Camp Hill, PA 17 ..read more