excel-vba

Possible bug? xlwings cannot run an Excel macro? [duplicate]

南楼画角 提交于 2020-01-15 01:51:10
问题 This question already has answers here : How do I call an Excel macro from Python using xlwings? (3 answers) Closed 3 years ago . I am having a problem getting xlwings to run a macro from Python. Despite following the code from xlwings documentation, I cannot get xlwings to execute an Excel macro. For instance, in Excel workbook named "Book.xlsm": ' in Excel workbook Book.xlsm Sub Test() Set ws = Worksheets("ABC") ws.Range("A1").Value = 10 End Sub This macro runs OK within Excel. But when I

Pivot Table: Detect When Pivot Field is Collapsed

ぐ巨炮叔叔 提交于 2020-01-14 22:13:02
问题 For my data shown in a pivot table, I have chosen to apply conditional formatting to certain portions of the data table to highlight values within certain ranges. It was interesting to figure out how to highlight the 2nd level row data differently from the subtotal data, but I was able to work it out. My VBA fires using the Worksheet_PivotTableUpdate event so that whenever the user changes the pivot table fields, the conditional formatting is updated appropriately. This method continues to

Operation must use an Updateable Query / SQL - VBA

时光怂恿深爱的人放手 提交于 2020-01-14 18:47:32
问题 I am trying to create a very dynamic macro that will update different tables in a Database, depending on what the user chooses. Each table has of course distinct titles and information. I'm having a problem with the update (when the user adds new records to an old Table). This is part of the code, the problem is when it gets to the ".update", I get the "Operation must use an Updateable Query" error. Dim DBCnn As ADODB.Connection Dim RecSet As ADODB.Recordset Dim sQRY As String Dim FilePath,

Positioning an Excel display using VBA

一世执手 提交于 2020-01-14 17:54:56
问题 Using VBA in Excel 2013. I would like to position the active worksheet with a specific cell (eg "X25") in the upper left corner. I have tried selecting cells off the currently displayed area, .Select ("ZZ200"), and then reselecting my target cell. I don't seem to be able to control where the target cell is positioned. Suggestions 回答1: Try this: Application.Goto Range("X25"), Scroll:=True This article has more information and options that you might find helpful: https://msdn.microsoft.com/en

Positioning an Excel display using VBA

穿精又带淫゛_ 提交于 2020-01-14 17:50:42
问题 Using VBA in Excel 2013. I would like to position the active worksheet with a specific cell (eg "X25") in the upper left corner. I have tried selecting cells off the currently displayed area, .Select ("ZZ200"), and then reselecting my target cell. I don't seem to be able to control where the target cell is positioned. Suggestions 回答1: Try this: Application.Goto Range("X25"), Scroll:=True This article has more information and options that you might find helpful: https://msdn.microsoft.com/en

SpecialCells method of Excel Range strange behaviour

◇◆丶佛笑我妖孽 提交于 2020-01-14 16:42:55
问题 I have written a macro to find blank cells from a certain range using SpecialCells method of excel range object. When i am trying to execute following code i get a exception as "No cells found". Sub test() Debug.Print Sheet1.Range("A1:D4").SpecialCells(xlCellTypeBlanks).Address End Sub Steps:- Open a new Excel instance. Press ALT + F11/ Open VBE Insert a new Module Paste the above code and run test macro as specified above. Output Received: Runtime Error '1004'. No Cells Found. Output

SpecialCells method of Excel Range strange behaviour

风流意气都作罢 提交于 2020-01-14 16:39:33
问题 I have written a macro to find blank cells from a certain range using SpecialCells method of excel range object. When i am trying to execute following code i get a exception as "No cells found". Sub test() Debug.Print Sheet1.Range("A1:D4").SpecialCells(xlCellTypeBlanks).Address End Sub Steps:- Open a new Excel instance. Press ALT + F11/ Open VBE Insert a new Module Paste the above code and run test macro as specified above. Output Received: Runtime Error '1004'. No Cells Found. Output

SpecialCells method of Excel Range strange behaviour

不打扰是莪最后的温柔 提交于 2020-01-14 16:38:34
问题 I have written a macro to find blank cells from a certain range using SpecialCells method of excel range object. When i am trying to execute following code i get a exception as "No cells found". Sub test() Debug.Print Sheet1.Range("A1:D4").SpecialCells(xlCellTypeBlanks).Address End Sub Steps:- Open a new Excel instance. Press ALT + F11/ Open VBE Insert a new Module Paste the above code and run test macro as specified above. Output Received: Runtime Error '1004'. No Cells Found. Output

Excel Macro send email

混江龙づ霸主 提交于 2020-01-14 15:49:13
问题 i have a report that i would like to send via excel. it will include the recipitents, subject and the information in the body. actually it could copy the cells in question. what i did so far is create a button and assign a macro to it with this code: Private Sub CommandButton1_Click() Application.Dialogs(xlDialogSendMail).Show arg1:=Sheets("Sheet1").Range("E3"), _ arg2:=Sheets("Sheet1").Range("E7") End Sub the problem is that this command sends the workbook as attachment. can someone help me

Excel Macro send email

懵懂的女人 提交于 2020-01-14 15:47:24
问题 i have a report that i would like to send via excel. it will include the recipitents, subject and the information in the body. actually it could copy the cells in question. what i did so far is create a button and assign a macro to it with this code: Private Sub CommandButton1_Click() Application.Dialogs(xlDialogSendMail).Show arg1:=Sheets("Sheet1").Range("E3"), _ arg2:=Sheets("Sheet1").Range("E7") End Sub the problem is that this command sends the workbook as attachment. can someone help me