excel-vba

Run Sikuli from button in Excel

有些话、适合烂在心里 提交于 2020-01-07 06:39:33
问题 I am new to VBA. In Excel sheet I have data. At the end of the every row I have an onclick button. My requirement is when I click on a button it has to run Sikuli from command prompt. Which command is used to open and run the command prompt in VBA? 回答1: I don't know sikuli, but if you want to run a command line from VBA code as part of a button click, look at the Shell command. Private Sub CommandButton1_Click() dblRetVal = Shell("java -jar %SIKULI_HOME%\script.jar path\yourScript.sikuli",

VBA - Set up a 2D array in VBA with random cells filled with color

社会主义新天地 提交于 2020-01-07 06:27:10
问题 I need to set up a 2D array and randomly fill a certain amount of cells in it with color, as if the array is a container and the cells are molecules. After that I need to perform actions on them. The code I tried was: Sub Insert_Molecules() Dim Molecules() As Integer Dim m As Integer, n As Integer Dim i As Integer, j As Integer m = 10 n = 10 ReDim Molecules(1 To m, 1 To n) As Integer For i = 1 To m For j = 1 To n Cells(i, j).Interior.Color = RGB(255, 0, 0) Next j Next i End Sub But what I

If cell contains value n, how can I create a column of n cells, each containing value n (and then repeat with another cell)?

老子叫甜甜 提交于 2020-01-07 05:49:13
问题 For the sake of simplicity, let's say I have a column of 5 numbers as follows:- 8 15 8 3 26 What I want to do is create a column composed firstly of 8 cells containing the value '8', then 15 cells containing the value '15', then 8 cells containing the value '8', and so on. This example would therefore result in a column length of 60 cells (however, my real-life column has over 200 numbers and would result in a column of about 2500 numbers!). Is this possible? Would it need a formula or a

How to display the file name from the path name in combobox

守給你的承諾、 提交于 2020-01-07 05:47:08
问题 I have written a code which will extract all the sub folders which is present inside a particular folder/Directory. Here is the code. ComboBox10.List = Split(CreateObject("wscript.shell").exec("cmd /c Dir ""C:\Users\inkapb\AppData\Local\Temp\EPC AutoTool\Projects\*."" /b /s").stdout.readall, vbCrLf) Here in the above code all the sub folder path is getting populated instead of the subfolder name. Can any one help me to achieve my requirement 回答1: I have a different piece of suggestion to

Set Legend Text Pie Chart

人盡茶涼 提交于 2020-01-07 05:46:20
问题 I have been trying to set my two legends using a VBA Macro. I want to change my two legends from 1 and 2 to Male and Female on my Pie Chart. I can change it manually by setting it in the "Select Data Source" dialog by setting "Category (X) axis labels" to "=Sheet1!$B$6:$C$6" (which is Male and Female) How do I do this with VBA, though? Here is my code... Sub Pie() For X = 7 To 13 Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("b" & X & ":c" &

Automatic Goal Seek Over Range of Cells

吃可爱长大的小学妹 提交于 2020-01-07 05:44:12
问题 I want to apply goal seek across several rows when there is a change to any cell in the work sheet. I want to apply this from row 7 to row 11. The first problem I have is that excel is crashing each time I run this. I am just starting to learn VBA so any help is much apreciated. Thank you! My code is below: Option Explicit Private Sub Worksheet_Calculate() CheckGoalSeek End Sub Private Sub CheckGoalSeek() Range("T7").GoalSeek Goal:=0, ChangingCell:=Range("V7") End Sub 回答1: You appear to be

Pull in Earlier Value Using Concatenation

拟墨画扇 提交于 2020-01-07 05:39:05
问题 I have code that works in some situations but not in others. I have this code: Public Sub ListBox2_LostFocus() ListBox2.Height = 15 With ListBox2 ThisIs_Sheet1_Test = "'" For i = 0 To .ListCount - 1 If .Selected(i) Then ThisIS_Sheet1_Test = ThisIs_Sheet1_Test & .List(i) & "','" End If Next i End With ThisIs_Sheet1_Test = Left(ThisIs_Sheet1_Test, Len(ThisIs_Sheet1_Test) - 2) End Sub that produces "ThisIs_Sheet1_Test". So when I run the code below, it gives me the selected values in the listbox

Copying Table from Excel into Powerpoint using a predefined template

 ̄綄美尐妖づ 提交于 2020-01-07 05:36:07
问题 I have written the below code to copy and paste two tables over two pages into Powerpoint as an image, what I would like to do however is if I have a table template already set up in Powerpoint with one blank row, copy the table rows from Excel into Powerpoint and if it goes over say 20 rows in Powerpoint start a new page with the same template. I have looked through lots of codes but nothing seems to be dynamic for what I am after in terms of copying to a pre set template. Thanks in advance

VBA UserForm Get Filename

十年热恋 提交于 2020-01-07 05:31:12
问题 I have constructed a UserForm that consists of 2 CommandButtons, each of which contains a Picture. The user is asked to select one of the two CommandButtons. I would like the filename of the picture selected to be copied to a cell in a worksheet. At the moment I can't figure out how to get the filename of the picture and so I have manually inserted the filename for each CommandButton, as such: Private Sub cmdQ2Opt1_Click() Worksheets("UserQuestionnaire").Range("C4").Value = "242.216.490" End

VBA Date values when inserted to Excel cells change their format

半腔热情 提交于 2020-01-07 05:29:09
问题 I have date variables formatted like: 25_December_2010 Once i use Dim strDate As String strDate = "25_December_2010" strDate = Replace(strDate,"_"," ") MsgBox strDate Surely enough a MsgBox pops up and gives me: 25 December 2010. However once i try to put the value into a cell for example: Sheets("Sheet1").Range("A1").Value = strdate Instead of populating the cell with: 25 December 2010 ; Excel acts on it's own accord and populates the cell with the vexing entry configuration: 25-Dec-2010 !