excel-vba

Refer To Controls in a Frame in Worksheet

寵の児 提交于 2020-06-28 03:03:31
问题 I have the Class Module , and I use it to handle Click event. I use Macro3() to link events with button on the Frame T1 and it works. I have hundred of Frames (ActiveX Control) with names like T1,T2,T3... . How do I reference the controls in each frame? I tried ActiveSheet.Shapes("T1").Controls("title_pic_tog") . It doesn't work. If we can make this work then I can use a variable to replace Shapes("t1") . Option Explicit Public WithEvents cBox As MSForms.ToggleButton Private Sub cBox_Click()

VBA Excel: FTP GetFile via WinINet

删除回忆录丶 提交于 2020-06-28 00:45:51
问题 I am trying to get an FTP Download operation to work with VBA Excel (on Excel 2013 x64, Windows 7 SP1 x64). I found some code that maps to the WinInet API and I can successfully upload files using the PutFile function but I am looking to get a GetFile function to work as well. To get working what I have so far, I used the following: second answer here, and this link. I've been mostly using the second answer from SO to get PutFile to work. I had to make some changes to the original code to

Hide specific sheets when closing workbook

人走茶凉 提交于 2020-06-27 23:30:20
问题 I'm creating some VBA code which should do the following: Users press a button a are required to input a code. When the input the correct code the team relevant code they get access to certain sheets. The sheets they get access to differs according to the team number and code they enter. So when they enter he password "banana": the sheets "Team_1" & Team_1_sub become visible. I now created the following code to achieve this: Sub filter_tabs() Dim answer As String answer = InputBox("Please

VBA Copying Excel Range to Different Workbook

柔情痞子 提交于 2020-06-27 23:05:09
问题 I am trying to find a way to copy a range in one workbook, in this case A6:J21,to another workbook. I thought it would be something like the following... currentWorksheet = xlWorkBook.Sheets.Item("Command Group") excelRange = currentWorksheet.Range("A6:J21") excelDestination = newXlSheet.Range("A6:J21") excelRange.Copy(excelDestination) But it gives me an error on excelRange.Copy(excelDestination) . The below code runs as expected, so I'm not sure where i'm going wrong here.. Dim xRng As

how to convert excel file to CSV file (pipe delimited) using excel vba

孤街浪徒 提交于 2020-06-27 19:05:08
问题 I want to convert the simple excel files into CSV(pipe delimited) using excel vba I tried to many code but cant get expected output following code I tried Sub mergeFiles() Dim xlwkbInput1 As Workbook Dim xlshtInput1 As Worksheet Dim xlwbfinalrpt As Workbook Dim xlshtfinalrpt As Worksheet Dim rcount1 As Long Dim xlwkbInput2 As Workbook Dim xlshtInput2 As Worksheet Dim xlapp As Excel.Application Set xlapp = New Excel.Application xlapp.Visible = True Set xlwkbInput1 = xlapp.Workbooks.Open

How to check if multiple items are selected in a pivot table?

二次信任 提交于 2020-06-27 17:45:08
问题 Is it possible to know which items are checked in a PivotTable filter in case MultipleItems are allowed? I only see .Visible property to check it but it only works if multiple items are not allowed. If multiple items are allowed and checked .Visible property, you only see "ALL" instead of all items selected. Any way to do it? Dim pvt As PivotTable Dim fld As PivotField Dim itm As PivotItem Dim flt As PivotFilter Dim i As Integer Set xbFuente = ThisWorkbook Set xlDatos = xbFuente.Worksheets(

xlwings module.py call python from excel

蹲街弑〆低调 提交于 2020-06-27 17:16:46
问题 I keep receiving this error while trying to call the module.py file from excel Traceback (most recent call last): File "<string>", line 1, in <module> File "F:\ana\module.py", line 6, in rand_numbers wb = Workbook.caller() # Creates a reference to the calling Excel file AttributeError: type object 'Workbook' has no attribute 'caller' When I replace wb = Workbook.caller() with wb = Workbook() I receive this error Traceback (most recent call last): File "<string>", line 1, in <module> File "F:

Clear the Excel cells format using VBA without clearing the NumberFormat

白昼怎懂夜的黑 提交于 2020-06-27 17:13:12
问题 Is it possible to clear Excel cell format and content (using VBA) without altering the “ NumberFormat ” of the given cell. I’ve tried with “ .ClearContents ” & “ .ClearFormats ”, but ClearFormats removed the NumberFormat of the cells too. Please suggest. 回答1: You could do something like this: Dim t t = Range("A1").NumberFormat Range("A1").ClearFormats Range("A1").NumberFormat = t It will save the number format then reapply it after clearing everything else. 来源: https://stackoverflow.com

Clear the Excel cells format using VBA without clearing the NumberFormat

帅比萌擦擦* 提交于 2020-06-27 17:11:59
问题 Is it possible to clear Excel cell format and content (using VBA) without altering the “ NumberFormat ” of the given cell. I’ve tried with “ .ClearContents ” & “ .ClearFormats ”, but ClearFormats removed the NumberFormat of the cells too. Please suggest. 回答1: You could do something like this: Dim t t = Range("A1").NumberFormat Range("A1").ClearFormats Range("A1").NumberFormat = t It will save the number format then reapply it after clearing everything else. 来源: https://stackoverflow.com

Open workbook if not already open, if already, then get that reference

末鹿安然 提交于 2020-06-27 15:47:29
问题 Ive a scenario to do some changes in a workbook in another workbook path. But the question is I need to check whether the workbook already open or not. If not I need to get that opened instance to a workbook variable. Here is the code Im using for checking whether workbook open or not and then the code for opening Function IsFileOpen(fileFullName As String) Dim FileNumber As Integer Dim errorNum As Integer On Error Resume Next FileNumber = FreeFile() ' Assign a free file number. ' Attempt to