Skip to content
- VBA Copy Paste Formats: Methods and ExamplesIn Excel VBA, copy formatting without changing cell contents by copying a source range and pasting with Paste:=xlPasteFormats. The basic pattern is…VBA & macros
- VBA Copy and Paste Excel Cells Into the Email BodyYes. In Excel for Microsoft 365 on Windows, VBA can copy a cell range and paste it into a message in classic…VBA & macros
- VBA Copy Paste Destination: How to Set the Target RangeIn VBA, specify the destination range with the Destination argument of Range.Copy: for example, Worksheets("Data").Range("A1:C5").Copy Destination:=Worksheets("Report").Range("E1"). The destination is the top-left cell…VBA & macros
- VBA Copy and Paste Data Between Excel SheetsTo copy a range from one Excel worksheet to another with VBA, use a macro that names both sheets and copies the…VBA & macros
- VBA Copy Dictionary: Methods, Code, and Deep CopiesTo copy a VBA Scripting.Dictionary, create a second dictionary and add each key and item from the first; there is no built-in…VBA & macros
- VBA Copy and Paste Values Only: Practical Methods and CodeTo copy values only with VBA, assign the source range’s values to an equally sized destination range: destinationRange.Value = sourceRange.Value. This writes…VBA & macros
- VBA Copy and Paste Values Into the Next Empty Row in ExcelTo copy a range as values into the next empty row in Excel, assign the source range’s .Value to a same-sized destination…VBA & macros
- VBA Copy and Paste Values Only in ExcelTo copy a range in Excel VBA and paste only its values, use Copy followed by PasteSpecial Paste:=xlPasteValues. For example, sourceRange.Copy and…VBA & macros
- VBA Copy and Paste Special: Examples and OptionsIn Excel VBA, copy a range and paste only selected content with Range.Copy followed by Range.PasteSpecial. For example, use Destination.PasteSpecial Paste:=xlPasteValues to…VBA & macros
- VBA Copy and Paste a File: Practical Code and Safe StepsTo copy a file with VBA in Excel for Microsoft 365 on Windows, use the FileCopy statement or FileSystemObject.CopyFile. Give the code…VBA & macros
- VBA Copy and Paste Cells: Examples and TipsIn Excel VBA, copy cells with the Copy method: specify a source range and a destination, such as sourceRange.Copy Destination:=destinationCell. To paste…VBA & macros
- VBA Convert String to Number: Functions and ExamplesTo convert numeric text to a number in VBA, use a conversion function such as CDbl for decimal values, CLng for whole…VBA & macros
- VBA Code Workbook Open: How to Run Macros at StartupTo run VBA when an Excel workbook opens, put a Workbook_Open event procedure in that workbook’s ThisWorkbook code module, then save the…VBA & macros
- VBA Code to Send Email from Excel Using Gmail SMTPYou can send email from Excel VBA through Gmail’s SMTP server using the Windows CDO library: create a Gmail app password, configure…VBA & macros
- VBA Code to Disable Copy and Paste in ExcelTo block the usual copy-and-paste keyboard shortcuts in Excel for Microsoft 365 on Windows, use VBA’s Application.OnKey method to disable Ctrl+C and…VBA & macros
- VBA Code to Disable Copy and Paste in ExcelIn Excel for Microsoft 365 on Windows, VBA can intercept common copy, cut, and paste shortcuts such as Ctrl+C and Ctrl+V. It…VBA & macros
- VBA Code to Delete Rows in Excel: Practical ExamplesIn Excel VBA, delete a worksheet row with Rows(rowNumber).Delete; when removing rows that meet a condition, loop from the bottom upward so…VBA & macros
- VBA Code to Copy and Paste Data in Excel: ExamplesTo copy a range to another worksheet with VBA, use Range.Copy and specify the destination: sourceSheet.Range("A1:D20").Copy Destination:=destinationSheet.Range("A1"). This copies the cells, including…VBA & macros
- VBA Code to Consolidate Excel Files into One WorkbookTo consolidate matching Excel files into one worksheet, place the macro below in the workbook you want to use as the destination,…VBA & macros
- VBA Code to Delete a Row in ExcelTo delete a worksheet row with VBA, use Rows(5).Delete for row 5. In a macro, qualify the row with the worksheet you…VBA & macros
- VBA Code to Copy a Range in ExcelIn Excel VBA, copy a range by calling Range.Copy and naming the destination range. For example, sourceSheet.Range("A1:C10").Copy Destination:=targetSheet.Range("A1") copies cells A1:C10 to…VBA & macros
- VBA Code to Copy and Paste Values in ExcelTo copy a range’s results without its formulas, use VBA’s PasteSpecial with xlPasteValues; for a fast transfer between same-sized ranges, assign one…VBA & macros
- VBA Close Workbook Without Saving: Methods and RisksTo close an Excel workbook with VBA and discard its unsaved changes, call the workbook’s Close method with SaveChanges:=False, as in ActiveWorkbook.Close…VBA & macros
- VBA Close Workbook Without a Save PromptTo close an Excel workbook without a save prompt, specify what should happen to unsaved changes: use Workbook.Close SaveChanges:=False to discard them,…VBA & macros
- VBA Clear, Copy, and Paste: Excel Macro ExamplesIn Excel VBA, use Range.ClearContents to remove values and formulas while keeping formatting, Range.Clear to clear a range more completely, and Range.Copy…VBA & macros
- VBA Check If a Worksheet Is ProtectedIn VBA, check a worksheet’s ProtectContents property: Worksheets("Data").ProtectContents returns True when that worksheet’s cell contents are protected and False otherwise. For a…VBA & macros
- VBA Check If a Worksheet Is Open in ExcelExcel does not open worksheets independently: a worksheet belongs to a workbook that is open in Excel. To check whether a named…VBA & macros
- VBA Check If Worksheet Exists: Code and ExamplesTo check whether a worksheet exists in VBA, try to set a Worksheet variable from the target workbook’s Worksheets collection and test…VBA & macros
- VBA Check If Workbook Exists: Paths, Files, and ErrorsYes. In VBA, use Dir$ with the workbook’s full file path and check whether it returns an empty string: an empty result…VBA & macros
- VBA Can’t Find Project or Library? How to Fix ItThe VBA error “Can’t find project or library” usually means the workbook’s VBA project has a broken reference to a library that…VBA & macros