excel-vba

Recursive call on the worksheet change in VBA

北慕城南 提交于 2020-01-04 06:16:27
问题 I have created the workbook with multiple sheet, i am trying to use WorkSheet_Change on Sheet1 , i.e. something change on sheet1 is getting copied to sheet2. Similarly if anything change to Sheet2 i want to make similiar change on Sheet1 as well. On doing so there is recursive call on both sheet please let me know how i can avoid this. 回答1: you should disable events when calling your macro: Sub Donot_Fire_Events() Application.EnableEvents = False ' Coding to skip these events Application

Extract embedded Excel worksheet data from Word

梦想的初衷 提交于 2020-01-04 06:07:53
问题 I have a batch of Word documents that have embedded Excel worksheets. Users have been entering data in the Excel sheet by double clicking the image of the sheet and opening an embedded Excel object. I need to get to the user entered data. Below is WORD VBA with a reference to the Microsoft Excel 15 library. (The Word and Excel object where created under Office 2010.) I can find the OLE object but I can't do anything with it. In the code below I tried to assign the object to a Worksheet object

Excel - Formula or Macro to fill a cell based on another cell that links to yet another cell

你。 提交于 2020-01-04 06:04:29
问题 In Excel, I am trying to make a cell based of the values contained in two other cells. I need Cells X and Y to have data based on Cells L and #, like so.... X Y L 1 2 3 4 5 6 A 6 1 1 6;1 6;1 7;1 7;2 7;2 8;1 B 7 2 4 6;1 6;1 7;1 7;2 7;2 8;1 So row A, has columns X and Y filled based of the values in the number columns. The specific number needed is what is filled in in column L. I am not sure the best way to phrase this question. If my example doesn't make sense, I can try to clarify or provide

Copy everything in a worksheet vba

谁说胖子不能爱 提交于 2020-01-04 06:01:12
问题 ' Copy wb.Sheets(wsSource.Name).Range("A1:W79").Copy ' Paste Special wbTarget.Sheets("Sheet1").Range("A1:W79").PasteSpecial xlValues wbTarget.Sheets("Sheet1").Range("A1:W79").PasteSpecial xlFormats This code allows me to copy everything in a range of A1:W79. How can I modify this Range so that it selects everything that contains value in a worksheet. For example, worksheet might contain values from C7:G20 etc. 回答1: I'd go like follows: With wb.Sheets(wsSource.Name).UsedRange .Copy With

VBA Fill out all cells between two cells

一笑奈何 提交于 2020-01-04 05:54:23
问题 I am currently trying to write some VBA code which will fill out all cells between two cells with the value of the two cells. Here is what I have : And I would like the code to fill out all cells in between like this: So, as you can see I would like all the cells in between to be filled out with the same value as the two corner cells. Any help is very much appreciated! Thanks in advance. 回答1: Place this in a new module and run test_DTodor : Option Explicit Sub test_DTodor() Dim wS As

Excel 2003 VBA: Move a sheet into a new workbook that is referenced by a variable

微笑、不失礼 提交于 2020-01-04 05:45:10
问题 I have a function that is meant to run the ShowPages() command of a PivotTable and then save each sheet to a separate file. Here's how I wish I could do it: Sub Split() ThisWorkbook.Sheets("Data").PivotTables("Data").ShowPages PageField:="Codename" Dim newWb As Workbook For Each s In ThisWorkbook.Sheets If s.Name <> "Data" Then Set newWb = s.Move #This is the line I'm trying to work out newWb.SaveAs Filename:="C:\Export\" + s.Name + ".xls" newWb.Close End If Next s End Sub Unfortunately, this

Deleting Signature In Outlook 2010 message generated via Excel VBA macro

☆樱花仙子☆ 提交于 2020-01-04 05:41:15
问题 I've been trying and reading around but I can't find the solution for this problem. I have an excel file where when the user presses a button: A) a range is selected and copied to the clipboard B) A new outlook messages opens based on a template C) E-mail will be sent "on behalf" off instead of the users' name/acount The user then has to add a date in the e-mail and paste the copied range into a certain part of the template. This is all ok and working BUT!!! outlook automatically adds the

Range SpecialCells ClearContents clears whole sheet instead

泪湿孤枕 提交于 2020-01-04 05:41:10
问题 I have a sheet in Excel 2010 which is setup as a pseudo form (I didn't create it, I'm just trying to fix it) so formatting suggests that the user can only enter in certain cells. Depending on certain functionality these areas need to be reset, i.e. cleared although formulae and standard/conditional formatting need to be kept. I have defined each of these cells/ranges as named ranges so I can easily loop through them using the following code: - Public Sub ResetDetailSheet() Dim nm As Name With

excel not refreshing all pivot tables

穿精又带淫゛_ 提交于 2020-01-04 05:39:15
问题 I am trying to refresh pivot tables using vba. I have code that modifies the underlying table query, and refreshes the query. Once that is done, it refreshes the pivot tables, which in turn will refresh a summary sheet. For some reason, the final pivot table is not being refreshed. It will refresh normally. Methods tried: 1. Dim PC As PivotCache For Each PC In ThisWorkbook.PivotCaches While DateDiff("s", PC.RefreshDate, Now) > 60 PC.Refresh Wend Next 2. Sheets("Pivots").PivotTables("Pivot1")

Deleting Rows From Filtered Range Via Macro

浪子不回头ぞ 提交于 2020-01-04 05:35:11
问题 I am having issues with the below code, which is trying to filter a set of data, then delete the visible rows. Currently I get a "Run Time 1004 Error: Delete Method or Range Class Failed" which occurs on the last line of my code. I found a similar question on the site, and the answer appears to be exactly what I have in my last line of code. Dim LastRow As Long LastRow = Worksheets("Orders").Range("A" & Rows.Count).End(xlUp).Row Worksheets("Orders").Range("A1:CU" & LastRow).AutoFilter Field: