excel-vba

How to apply ShapeStyle to a specific Series of a Chart in Excel using VBA?

痴心易碎 提交于 2020-01-04 01:57:08
问题 How do I programatically apply a ShapeStyle to a set of Points from a single Series of a Chart using vba? It seems I need a "Shapes" object that contains only the points from the series I am trying to format? Some information is here: http://peltiertech.com/WordPress/programming-excel-2007-2010-autoshapes-with-vba/ under the "Setting Border and Fill Styles" section I have pseudocode but I have no idea how to create the Shapes object with only the items I want in it ' Applies desired

Permission Denied opening an Excel File using Excel 12.0 Library & VB6

你离开我真会死。 提交于 2020-01-04 01:23:15
问题 I have used Excel in my VB6 apps many times before, and have never run into such a weird problem trying to accomplish something very easy.. I am trying to open an excel (xls or xlsx) file and read through values, as you can probably see. When I try to open the file, I get an error 70 (permission denied) error. The odd thing is that there is no other instance of excel open (in task manager apps or processes). No one else is trying to access the file whatsoever. I can open the file in excel

Excel VBA print results of immediate window in a cell(s)

北城以北 提交于 2020-01-04 00:58:12
问题 I have a macro that times how long each query takes to run and output the time to the immediate window. I there a way to set it to output to cells? Macro: Sub TimeQueries() Dim oSh As Worksheet Dim oCn As WorkbookConnection Dim dTime As Double For Each oCn In ThisWorkbook.Connections dTime = Timer oCn.Ranges(1).ListObject.QueryTable.Refresh False Debug.Print Timer - dTime, oCn.Name, oCn.Ranges(1).Address(external:=True) Next End Sub Immediate Window Output: 6.609375 Query1 [YEtest.xlsm]Query1

How do I insert text at my cursor location in Word?

北慕城南 提交于 2020-01-04 00:12:39
问题 I'm trying to have my Excel macro insert some text at my cursor location in a already-opened Word Document. This is what I have written. I'm aware that the ActiveDocument.Range has the Start and End arguments, but I cannot seem to be able to assign them the "current selection" as a value. Help? Thanks? Sub InsertText() Dim rngTemp As Word.Range Set rngTemp = ActiveDocument.Range With rngTemp .InsertAfter "This is my sample text" .Font.Name = "Tahoma" .Font.Size = 11 .InsertParagraphAfter End

Excel invisible question mark

拈花ヽ惹草 提交于 2020-01-03 21:11:04
问题 I have an extracted information from a system into an Excel file. The names "Leone" seem the same but Excel recognize it differently. Leone ​Leone The length of the string is not the same, and if I check the value with VBA an invisible ? is the first character. Could you help me how to get rid of the invisible characters? 回答1: To get rid of all invisible ? you may try this. Sub CleanUnicode() Dim n As Long, strClean As String, strChr As String Dim ws As Worksheet Set ws = ThisWorkbook.Sheets(

Automatically execute some code after the UserForm is drawn

China☆狼群 提交于 2020-01-03 20:02:58
问题 I have created a UserForm where the user is required to fill-in three fields. The macro attempts to auto-detect these fields' values in the UserForm_Initialize() event, then displays the found values in the three fields, but the user can change them. The auto-detection takes a few seconds, though, and delays the appearance of the UserForm. I'd like the UserForm to appear with its fields blank before the auto-detection procedure, then have the auto-detection procedure fill the fields

Why can't I set Application.ReplaceFormat.NumberFormat to some valid formats?

人盡茶涼 提交于 2020-01-03 19:23:12
问题 I'm trying to use an Excel Macro to reformat a spreadsheet exported using OLE-Automation The following code works OK: Application.FindFormat.NumberFormat = "#,##0.0000000" Application.ReplaceFormat.NumberFormat = "#,##0.00" Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:= _ xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True if I change the ReplaceFormat to Application.ReplaceFormat.NumberFormat = "#,##0.0" to display only 1 decimal place, I get an error

VBA Excel action when closing workbook

纵饮孤独 提交于 2020-01-03 17:48:54
问题 Is is possible automatically let Excel do an action when someone closes the file? I'm pretty new to VBA an stackoverflow, so please have mercy.. Situation: I have an Excel file which is also used bij several other people. This file publishes a mhtml file whens saving. This mhtml file will be saved with the date of yesterday like "Dashboard 2015-01-12". The seen data in the mhtml file has to contain the date related to the file name. The data seen depends on a single cell in this excel file,

VBA Excel action when closing workbook

巧了我就是萌 提交于 2020-01-03 17:47:57
问题 Is is possible automatically let Excel do an action when someone closes the file? I'm pretty new to VBA an stackoverflow, so please have mercy.. Situation: I have an Excel file which is also used bij several other people. This file publishes a mhtml file whens saving. This mhtml file will be saved with the date of yesterday like "Dashboard 2015-01-12". The seen data in the mhtml file has to contain the date related to the file name. The data seen depends on a single cell in this excel file,

Extract Year from Date Using VBA in Excel

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 17:33:48
问题 I have an excel workbook with several sheets. What I need to do is transfer the year from a column in one sheet to another sheet. I can get the column to transfer over fine, but I can't get it to give me just the date. The date is in dd-mon-yy format (ex. 14-Jul-14 ). What I need is to get it in yyyy (ex. 2014 ). Any assistance would be great. The code I'm attempting is this, but it doesn't work. [...] For I=5 to 5 If Not TransferCol (5) = 0 Then Worksheets ("Results").Cells.(Row, StartColumn