excel-vba

push to git from vba on windows

喜夏-厌秋 提交于 2020-06-17 03:37:48
问题 I am developing word and excel macros, however to keep revision control and track changes I would like to use GitLab So what I have done so far is to have a code which export out all vba code to a folder on my PC(Z:/Dokumentstyring/GIT), when I run my publish sub routine: Private Sub publish() ThisDocument.save Call ExportVisualBasicCode ' Here I would like to automatically push the code to GIT Call CloseAll End Sub Then I manually go into git shell and type: git config --global user.name

Excel macro - open specific word file

余生长醉 提交于 2020-06-17 02:33:57
问题 I haven't found anything that can help me. I'm trying to open a certain word file, have some data written in it and saved under a different name. This is what I have so far: Dim appWD As Word.Application Set appWD = CreateObject("Word.Application.8") Set appWD = New Word.Application Dim docWD As Word.Document Set docWD = appWD.Documents.Open("C:\Documents and Settings\Excel macro\Standaard.docx") appWD.Visible = True ' ' Data is selected and copied into "Design" ' Copy all data from Design

Is it possible to create a macro, that will create a hyperlink, that will run a macro

我只是一个虾纸丫 提交于 2020-06-17 02:07:12
问题 I'm just wondering if you can create a Macro, that will hyperlink a cell and assign a separate macro to it? I know you can use a hyperlink to run a macro using the following Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Call Macro Name End Sub I also know you can use a macro to create a Hyperlink using the following With Worksheets(1) .Hyperlinks.Add Anchor:=.Range("a5"), _ Address:="", _ ScreenTip:="", _ TextToDisplay:= "" End With Is there anyway to put these together? Or

How do I use RefersToRange?

吃可爱长大的小学妹 提交于 2020-06-16 23:45:13
问题 Can anyone tell me how to use RefersToRange in vba? and what and when is the need of it. Please provide with simple example first. Thanks in advance. 回答1: In Excel, there is the concept of a named range , that is a range of cells which has a name attached to it. This is represented by the Name object. The RefersToRange method: Returns the Range object referred to by a Name object. For example, let's say I want to read the values only in the print area of the current worksheet. I need the Name

How do I use RefersToRange?

别等时光非礼了梦想. 提交于 2020-06-16 23:44:29
问题 Can anyone tell me how to use RefersToRange in vba? and what and when is the need of it. Please provide with simple example first. Thanks in advance. 回答1: In Excel, there is the concept of a named range , that is a range of cells which has a name attached to it. This is represented by the Name object. The RefersToRange method: Returns the Range object referred to by a Name object. For example, let's say I want to read the values only in the print area of the current worksheet. I need the Name

VBA - Count Non Blank Cells Using Cell Reference

試著忘記壹切 提交于 2020-06-16 04:23:30
问题 In VBA, using Excel 2016, I am trying to count the number of non-blank cells for a given range but using only the cell integer reference. I've tried the following: WB.Sheets(1).Range(Cells(2, X), _ Cells(2, Y)).Cells.SpecialCells(xlCellTypeConstants).count Where X and Y are cell references for the columns. Please assist. 回答1: Try this: Range(WB.Sheets(1).Cells(2, X), _ WB.Sheets(1).Cells(2, Y)).Cells.SpecialCells(xlCellTypeConstants).count You should add the workbook and worksheet before the

Exporting charts as Image sometimes generates empty files - Excel VBA

对着背影说爱祢 提交于 2020-06-14 07:32:58
问题 I'm doing a macro that exports all the charts in the sheet and then opens Outlook and attaches them. However, I've noticed, several times the charts do export but as 0KB (the file is created, but the image can't be seen) But it doesn't happen to all the charts. Just most of them and sometimes, it generates them all without a problem. (When I execute the code step by step, all charts generate without a problem, also after executing the step by step, then I execute it normally and all charts

Exporting charts as Image sometimes generates empty files - Excel VBA

情到浓时终转凉″ 提交于 2020-06-14 07:32:13
问题 I'm doing a macro that exports all the charts in the sheet and then opens Outlook and attaches them. However, I've noticed, several times the charts do export but as 0KB (the file is created, but the image can't be seen) But it doesn't happen to all the charts. Just most of them and sometimes, it generates them all without a problem. (When I execute the code step by step, all charts generate without a problem, also after executing the step by step, then I execute it normally and all charts

How to change cell value using Worksheet_change event without triggering a second call

夙愿已清 提交于 2020-06-12 08:17:00
问题 I'm working on a simple worksheet, and I need to change some data in the cells depending on the user input; those changes are made using the Worksheet_Change event. However, when I change another cell, the event is triggered again, so it becomes quite a headache (it's kind of a "chicken-and-egg" scenario). Example: private sub Worksheet_Change(ByVal Target as Range) with target ' Only cells in column C are unlocked and available for edition select case .row case 4 if .value = 1 then

How to destroy an object

偶尔善良 提交于 2020-06-11 16:48:47
问题 It seems that Set Object = Nothing didn't destroy the Fs Object in this code: Sub Test2() Dim Fs As New FileSystemObject Set Fs = Nothing MsgBox Fs.Drives.Count ' this line works End Sub The last line works with no errors!. thats mean Fs Object is still exists, right?. So how to destroy this Fs Object. 回答1: Another way to ensure proper destruction of an object, is to yield its object reference to a With block (i.e. don't declare a local variable): Sub Test() With New FileSystemObject MsgBox