1. U

    keep thisworkbook as the workbook that is displayed after macro is finished running

    Hi all, I have created a code that copies data from one workbook (Workbook1) and pastes it into another workbook (Worbook2). The code works fine but after it is finished, it displays Workbook2 on the computer screen. I would like Workbook1 to be the workbook that shows up after the code is...
  2. B

    Open Outlook When Excel opens

    I have a workbook that has a few outlook functions built in to it but outlook needs to be open the way the codes are written. How do I get Outlook to open when this file opens? I know the code has to go in the ThisWorkbook section of the objects. Thanks in advance
  3. S

    How to combine two pieces of code on one spreadsheet

    Hello All, I have two pieces of code. The first is a "select and move" piece of code to take a line from one worksheet and transfer it to another worksheet dependent on cell content, it also unlocks and then locks the worksheet to perform this task. The second piece of code I have copied...
  4. P

    ThisWorkbook Question

    Hi All, I'm trying to use a different code structure for the NAMED tab of "Tab_ONE" with the following: ThisWorkbook.Sheets("Tab_ONE").Range("B11:X180")) Is there anyway to restructure this to use the for example, Worksheet(2) in lieu of "Tab_ONE"?? Please let me know, if you should have...
  5. CsJHUN

    macro change back to "thisworkbook" from "active workbook"

    Hi guys, i have this (snipet): Private Sub readreqdb() Sheets("allrequest").Activate ActiveSheet.Unprotect Password:="asdqwe" dblink = Sheets("settings").Range("AG11").Value Workbooks.Open dblink, ReadOnly:=True, Password:="asdqwe" Set reqdb = ActiveWorkbook For i = 1 To Sheets.Count...
  6. E

    Simple Save As PDF code

    Hi, I(VBA novice) am looking for a simple save as PDF code to add in my excel sheet, using the ThisWorkbook. Thank you.
  7. W

    macro to fix macro?

    There is a spreadsheet that is print protected[indented for third party input directly into the sheet - like a questionnaire]. It was print protected in the "Thisworkbook" so that the 3rd part would need to populate it and return it electronically. However we shot ourselves in the foot as WE...
  8. M

    Closing ActiveWorkbook but not ThisWorkbook

    My program opens a spreadsheet. I want to close this one using the x symbol without asking me if I'd like to close all other spreadsheets. I have this written in my ThisWorkbook coding section. Public swb As String Private Sub Workbook_Open() Application.ScreenUpdating = False swb...
  9. P

    Unable to select a sheet while copy pasting data

    Hi All, Im trying to copy a data from 1st excel to 2nd excel. While im about to select a sheet in 2nd file im getting "Subscript out of range" as error. I have used the same code earlier for several other excels but I haven't get this kind of error. Can someone help me to fix this. Below is my...
  10. R

    Thisworkbook property

    In the below lines the first 6 and the 11th work, but lines 7, 8, 9 and 10 don't work Do you have to use Sheets when using ThisWorkbook [myrange] = "Yes" [myrange].Offset(0, 1) = "Yes" Sheets("Sheet1").[myrange].Offset(0, 2) = "Yes" Range("myrange").Offset(1, 1) = "Yes"...
  11. B

    Thisworkbook Object in VBE crashes Excel

    I have a new Lenovo i7 with 32 bit Office 2016. When I select Thisworkbook object in the VBE, Excel crashes. Searches have not found a solution and extracting to bas or cls files fail to import to clean wkb on selecting the object. Any solutions? Brendan
  12. MUKESHY12390

    Multiple workbook under one workbook

    Hi all, today I have observed strange thing, while writing code I usually see just one workbook ( Thisworkbook - with excel icon) under VBA project. I don't know what happened now I can see two workbook ( thisworkbook and Output workbook). it seems sheet got convereted into workbook. Is...
  13. L

    workbook vs thisworkbook and worksheets(1) vs activesheet

    Hi I understand I can replace worksheets(1) with thisworkbook in the code below. I checked both Workbook and Thisworkbook and I found they are not identical 100%. So how can I replace one with another if they are not identical. Is it technically ok to replace one with another or I should put in...
  14. L

    VBA environment and Module

    Hi I have excel 2013. When I click on Developer-->VBA, excel will open VBA environment. Under project, I see 2 entries 1) Sheet1 (Sheet1) 2) ThisWorkbook My understanding, if I want to write a code to run for ONLY sheet1 then I click on sheet1 and write the code. At same token, if I want to...
  15. L

    Recreating scripts to include ThisWorkbook with all ranges and worksheet calls.

    I have created a directory and it works great until you have it open with other documents... So I need to limit it to only this workbook but with the different types of script below I'm not sure how... It's not as simple as just placing ThisWorkbook in front of it... Any assistance on getting...
  16. Nelson78

    Copy a sheet from a closed workbook and paste on an existing sheet of this workbook

    Hello everybody. I need to copy the sheet ("Alpha") from the closed workbook ("Beta") and paste it in thisworkbook sheet ("Alpha"). Sub copy_alpha() Application.ScreenUpdating = False Set wb1 = thisworkbook Set file2 = Workbooks.Open("S:\xxxx\yyyyyy\Beta.xls")...
  17. P

    how to stop pop up and can the coding be minimised

    Hi, good morning, i have the code below but i was wondering if there was anything that could be done to make it abit more compact? also is there anyway to stop the pop up of the file? Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim lookuprng As Range Set wb1 =...
  18. L

    Can I save a macro to a specific workbook?

    Hi there, For clarification what I am looking to do is to try and save the macro to the work book so others who use it don't have to import the macro. I managed to add an auto lookup macro to the ThisWorkBook in VBA but that applies the macro when you open the workbook. I want a button or...
  19. T

    Excel crashes when attempting to view ThisWorkbook code

    I have a new PC (Windows 10 Pro 64 bit) with a fresh install of Office 2016 32 bit. In VBA editor, clicking (left or right) on ThisWorkbook causes Excel to crash and either close or restart (different behavior at different times). This occurs in a new, blank Excel file and in files with...
  20. Nelson78

    Application.OnTime : attempt to avoid loops

    Hello everybody. I need my macro "Test" running every day at 11:30. Writing in ThisWorkbook Private Sub Workbook_Open() Application.OnTime TimeValue("11:30"), "Test" End Sub is not a good idea: it does not work, probably because of a loop. So, I've tried to identify univocally date and...

Some videos you may like

This Week's Hot Topics