excel-vba

Incorporating refedit into Vlookup userform

亡梦爱人 提交于 2020-01-05 14:10:14
问题 I have a vlookup userform which autofills the details in the form based on the seat n°. Now I want to incoroporate a ref edit to paste these data from the text box to the cells the user chooses with the refedit. Hence i would need some help in going about these. This is the code i have used. I potentially want to insert 3 refedit boxes for user to select the cell they want to paste each of the data ( Name , Dept and Ext No .) from the textbox . See my code below: Option Explicit Private Sub

VBA code to send email from Secondary email address in Outlook

假装没事ソ 提交于 2020-01-05 13:58:11
问题 I am using Excel 2010 on W7 x64, and send email from Outlook using code from Ron de Bruin. I have an individual and group email address that I send from, and am looking for a way to send from the group address by changing it in VBA. The secondary address is not set up as an actual account in Outlook. If I go to File - Account Settings in Outlook, there is only one email account listed. The group email address simply forwards to the group. I created an actual account for the group box, and

VBA Error Run time 13 error Type Mismatch can't find where it's happening

做~自己de王妃 提交于 2020-01-05 13:36:20
问题 I have been searching for hours trying to find how to fix my code but the problem is that I can't tell where the error is coming from! Please help! I keep getting "run time error 13 Type mismatch" Sub Mail_Every_Worksheet() Dim sh As Worksheet Dim wb As Workbook Dim FileExtStr As String Dim FileFormatNum As Long Dim TempFilePath As String Dim TempFileName As String Dim OutApp As Object Dim OutMail As Object TempFilePath = Environ$("temp") & "\" If Val(Application.Version) < 12 Then FileExtStr

Dynamic Depending Lists in Separated WorkSheets in VBA

。_饼干妹妹 提交于 2020-01-05 12:58:21
问题 I'm not really expert in VBA and I have a problem with my code and I don't know how to solve it. (The code is from: http://siddharthrout.wordpress.com/2011/07/29/excel-data-validationcreate-dynamic-dependent-lists-vba/) I'm working with 8 dynamic dependent lists, and I thought the best way to automate the process and avoid to modify the macro in a future if I modify the lists was a VBA code. Trying to find the correct code, I'm just working with to lists. For after, apply it for all lists. I

Visual Basic global variables in Excel Macro

风格不统一 提交于 2020-01-05 12:35:13
问题 I writing macro for excel on VB. There is a structure: Forms Form1 Modules Main In the Form1 I have Button click event Public Sub CommandButton1_Click() MsgBox GLOBALVAR 'I need access to GLOBALVAR here End Sub In the Main I have procedure Test Sub Test GLOBALVAR = "VALUE" End Sub How I can implement it? I can't create Module GlobalVariables End Module Due to Excel does not support this construction! 回答1: Add a Public MyGlobalVariable as String in the Module1 and it becomes accessible in your

Visual Basic global variables in Excel Macro

邮差的信 提交于 2020-01-05 12:35:09
问题 I writing macro for excel on VB. There is a structure: Forms Form1 Modules Main In the Form1 I have Button click event Public Sub CommandButton1_Click() MsgBox GLOBALVAR 'I need access to GLOBALVAR here End Sub In the Main I have procedure Test Sub Test GLOBALVAR = "VALUE" End Sub How I can implement it? I can't create Module GlobalVariables End Module Due to Excel does not support this construction! 回答1: Add a Public MyGlobalVariable as String in the Module1 and it becomes accessible in your

VBA: Format cell on #VALUE Error

此生再无相见时 提交于 2020-01-05 12:21:30
问题 I've created a function that searches a specific value on a range and returns adjacent characteristics. Function Busca(valor As String) Dim bus(0 To 1) bus(0) = Worksheets("Sheet2").Range("A1:A10").Find(valor, LookAt:=xlWhole). _ Offset(0, 1) bus(1) = Worksheets("Sheet2").Range("A1:A10").Find(valor, LookAt:=xlWhole). _ Offset(0, 2) Busca = bus End Function If there is no match for valor in A1:A10 , the function returns {#VALUE,#VALUE} , wich is ok, but I'd like to return instead something

Deleting Duplicates with VBA - Excel 2003

空扰寡人 提交于 2020-01-05 12:08:28
问题 I was wondering if anyone would know of any VBA code that would get rid of duplicates. For example, in Column D, I want to keep the first instance of the ID, and get delete the duplicate(s). Regards Greg 回答1: Ok, that should work for you. That Routine delets all double Id'd in the Column C Option Explicit Sub DeletDuplicate() Dim x As Long Dim LastRow As Long LastRow = Range("C65536").End(xlUp).Row For x = LastRow To 1 Step -1 If Application.WorksheetFunction.CountIf(Range("C1:C" & x), Range(

Excel VBA “Group by”-like selection

我们两清 提交于 2020-01-05 10:37:21
问题 I want to get data from an Excel worksheet in an SQL-like mode. Meaning, I have following columns: code, type, name, product_code, price, quantity . What I want to do is get the data from this sheet like it was a db table and I execute the following: select code, type, name, product_code, sum(price), sum(quantity) from table group by code, type, name, product_code How can I do this in VBA? 回答1: Order your data by code, type, name, product_code , then write a loop that iterates through every

Print dates in proper format

╄→гoц情女王★ 提交于 2020-01-05 10:37:18
问题 I have an excel workbook with many dates. On the worksheet they are in a format of "mm/dd/yy hh:mm" What I see in the white box above the sheet is in the format of "dd/mm/yy hh:mm" I need to print the worksheets into text files, but when I do so, it's printing in the format of dd/mm/yy hh:mm , Instead of mm/dd/yy hh:mm . Here's the code: For i = 1 To LastRow For j = 1 To LastCol If j = LastCol Then DataLine = DataLine + Trim(Cells(i, j).Value) Else DataLine = DataLine + Trim(Cells(i, j).Value