excel-vba

Create Excel Consolidated Worksheet with multiple sources in VBA

旧街凉风 提交于 2020-06-18 04:26:48
问题 I am trying to Consolidate multiple Worksheets on one Worksheet using VBA. How do I tell VBA to only consolidate the worksheets that are visible? 回答1: I took Jerry Sullivan's answer from http://www.mrexcel.com/forum/excel-questions/620641-using-visual-basic-applications-perform-consolidate-function.html and tweaked it. The MSDN site was of some help in understanding the arguments, for example that the array of ranges must contain fully qualified addresses in R1C1 style. Of course you gave no

Writing variable to a file using macro

时光怂恿深爱的人放手 提交于 2020-06-18 04:17:43
问题 I need to write data from a macro to a text file. I am using the below code: VAR_ABC = "Deployment1.txt" Dim FlName As String filesize = FreeFile() Open FlName For Output As #filesize Write #filesize, "Hello World!" Write #filesize, "" & VAR_ABC; Close #filesize I have below questions: The output in my file contains double quotes i.e. "Hello World" "Deployment1.sh" How to get rid of these double quotes in my text file? Is there a way to write multiple lines in a better way(with new line

excel files loop

风流意气都作罢 提交于 2020-06-18 03:13:35
问题 In my excel sheet I'm using formulas which referring to external sheets. Instead of manually changing the value in cell E7 (where I insert name of external sheet), I want to write an macro to open all of external sheets, change reference value in E7 and copy the generated values. Unfortunately my code does't work - Excel can't "see" the values in the external sheet. What should I change? Sub lista_plik() Dim oExcel As Excel.Application Dim oWB As Workbook Set oExcel = New Excel.Application

Using VBA in the Workbook_SheetChange Event

[亡魂溺海] 提交于 2020-06-17 14:56:49
问题 I am trying to create a log of when a specific range (G2:G103) within a specific worksheet (named "FORMULAS") has any changes made to it. This is a workbook that is viewed by many people multiple times a day, and it would be helpful for me to have record of when changes were made to the range in question that I can keep track of behind the scenes. I would like the log of changes to be contained within another worksheet (named "ActivityLog") starting in column E with the username and now

Python code to refresh the connection in individual excel sheet

假装没事ソ 提交于 2020-06-17 14:37:12
问题 I am a beginner in python. I have written few DBQ statements in excel to fetch result in excel which should be refreshed whenever the excel is opened. Have given the correct setting in connection properties. Below is my python code for refreshall:- import win32com.client import time xl = win32com.client.DispatchEx("Excel.Application") wb = xl.workbooks.open("D:\\Excel sheets\\Test_consolidation.xlsx") xl.Visible = True time.sleep(10) wb.Refreshall() I have 3 sheets in the excel file, which

Insert picture corresponding to cell value using excel macro

不问归期 提交于 2020-06-17 14:15:09
问题 I'm using the macro below to insert the picture corresponding to the value in Cell P2 into cell Q2. This works for the one cell selected (P2 in this case). I want to create a loop to do the same action for the rows in Column P range (P2:P500) that are not blank. Sub Picture() Range("Q2").Select Dim picname As String picname = "C:\Users\kisnahr\Pictures\Test\" & Range("P2") & ".bmp" 'Link to the picture ActiveSheet.Pictures.Insert(picname).Select With Selection .Left = Range("Q2").Left .Top =

Insert picture corresponding to cell value using excel macro

情到浓时终转凉″ 提交于 2020-06-17 14:14:03
问题 I'm using the macro below to insert the picture corresponding to the value in Cell P2 into cell Q2. This works for the one cell selected (P2 in this case). I want to create a loop to do the same action for the rows in Column P range (P2:P500) that are not blank. Sub Picture() Range("Q2").Select Dim picname As String picname = "C:\Users\kisnahr\Pictures\Test\" & Range("P2") & ".bmp" 'Link to the picture ActiveSheet.Pictures.Insert(picname).Select With Selection .Left = Range("Q2").Left .Top =

VBA-delete shapes

南楼画角 提交于 2020-06-17 13:34:51
问题 I have this code that creates shapes in page 2 when I write something in A1:A3 and places the textbox according to what I write in B1:B3, the problem is that when I delete the value of A1 I want the textbox to be deleted, but it doesn't delete the textbox. I also tried : Call getCaixas(Worksheets(2), Target.Address).Delete after dim box as shape. In this option it did erase the textbox but then all the textboxes were created on the top of the page. Private Sub Workbook_SheetChange(ByVal Sh As

How to catch row(s) deleted in Excel VBA

我的未来我决定 提交于 2020-06-17 13:11:48
问题 I would like to get the row numbers of each deleted row after or before the rows are deleted in VBA. There is an Event BeforeDelete() but when I delete a row it is not triggered? Is there any other events or ways I could do this? Here's kinda what I want: Private Sub Worksheet_BeforeDelete() Dim i As Integer i = ActiveCell.Row End Sub 回答1: The following event macro will tell you whenever an entire row is deleted or inserted: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Rows

How to catch row(s) deleted in Excel VBA

徘徊边缘 提交于 2020-06-17 13:09:08
问题 I would like to get the row numbers of each deleted row after or before the rows are deleted in VBA. There is an Event BeforeDelete() but when I delete a row it is not triggered? Is there any other events or ways I could do this? Here's kinda what I want: Private Sub Worksheet_BeforeDelete() Dim i As Integer i = ActiveCell.Row End Sub 回答1: The following event macro will tell you whenever an entire row is deleted or inserted: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Rows