excel-vba

Excel VBA object sub call with 2 object parameters gives compile error: expected =

旧城冷巷雨未停 提交于 2020-01-07 03:47:09
问题 I am calling an object's subroutine in Microsoft excel vba. The sub has 2 parameters, both objects themselves. The line of code I typed is giving an error-> Compile Error: Expected = Here is the section of code that it occurs in: ' Copy the info from the old sheet and paste into the new sheet Dim employee as CEmployee For i = 2 To eswbMaxRow Set employee = New CEmployee employee.setNames (eswb.Worksheets("Employee Info").Cells(i, wbColumns.infoNameCol).value) employee.loadFromAnotherWorkbook

VBA If then statement + left

爱⌒轻易说出口 提交于 2020-01-07 03:44:26
问题 I'm very new to using VBA, and I am trying to create a code with these rules (Please see image for context): If Column B cell has the text "GBP", then go across to the Adjacent cell in Column C. If the first 2 letters of the C cell begins with RB, then post the text "Royal Bank of Scotland" in an adjacent Cell D, if the first 2 letters are HC, then post the text "Corporate" in an adjacent Cell D instead. If Column B cell has the text "USD", then go across to the Adjacent cell in Column C. If

Iterate through spreadsheets in a folder and collect a value from each

本小妞迷上赌 提交于 2020-01-07 03:40:10
问题 I'm trying to write code that on Commandbutton2_Click searches through the folder that the file is in, takes a value from the same cell in each file and adds these together. I have this: Private Sub CommandButton2_Click() Dim lCount As Long Dim wbResults As Workbook Dim wbCodeBook As Workbook Dim strFolderPath As String Dim strToolNumber As String Dim RingCount As Integer RingCount = 0 strToolNumber = CStr(Sheets("Sheet1").Range("B9").Value) strFolderPath = "T:\Engineering\Tooling\Tooling

Highlight Duplicates Not Next To Each Other Using Conditional Formatting

旧巷老猫 提交于 2020-01-07 03:21:51
问题 We have a list of parts in Excel in a certain order. For reasons I won't get into, we need to highlight when there are duplicates that aren't next to each other. Currently, I'm using this formula in a conditional format to do the job. =AND(COUNTIF($A$2:$A$82,$A2)>1,$A1<>$A2,$A2<>$A3) This mostly works well except in cases where there are pairs of duplicates like in the example below, we would want FO-1694 to be highlighted, because they aren't all next to each other. But we would not want

VBA Copy and Paste Column based of Column Heading

我的梦境 提交于 2020-01-07 03:19:07
问题 I hope you can help. What I am trying to achieve is this: I want the VBA to search through column headings to find a heading that contains the text "CountryCode" once it finds this I want it to cut this column and paste it into the sixth column. My attempt at code is below but it not working correctly I have attached screen shots for better understanding. I know Destination:=Worksheets("Sheet1").Range("E5") is wrong I just cant seen to get it to paste into the newly created F Column Screen

Referencing a shared calendar

江枫思渺然 提交于 2020-01-07 03:19:04
问题 I tried to run the code from this question: Exporting Outlook calendar data to Excel file - Shared calendars and VBA My code modification. Set olNS = olApp.GetNamespace("MAPI") Set myCalItems = olNS.CreateRecipient("theOtherUser") myCalItems.Resolve myCalItems.GetSharedDefaultFolder I got error 13 Type mismatch. I've testing different combinations without result. I tested this example too: MSDN link This info is useful but not enough: http://www.snb-vba.eu/ I need to export shared MS Outlook

What's different beetwin Left property in ChartObjects and TableRange?

本秂侑毒 提交于 2020-01-07 03:17:10
问题 I used the code below to set TableChart's position with it's related PivotTable position. My sheets direction is Right to Left. Sheets("sheet1").ChartObjects("InsuranceChart").Top = Sheets("sheet1").PivotTables("pvtReport").TableRange1.End(xlDown).Offset(2).Top Sheets("sheet1").ChartObjects("InsuranceChart").Left = Sheets("sheet1").PivotTables("pvtReport").TableRange1.Left The problem is in second line, returned value of two Left property. (I checked this two with Msgbox ) Left one that is

Loop through column and check if cell contains specific chars

随声附和 提交于 2020-01-07 03:11:27
问题 I'm in need of help trying to figure if Instr function will do this trick. In a cell i have some text and numbers (ex: Overlay 700 MHz - 06_469 ) See the final numbers? 2 numbers followed by _ (underscore) or any letter and then 3 more numbers. Is there any way of searching for this in a specific column and if found, copy only these specific combination? NOTE: it can be anywhere in the cell, in beginning, end, middle, etc..... 回答1: Use [regex] to look for a 'two number-underscore-three number

VBA Excel - Loop through worksheet creating tables

*爱你&永不变心* 提交于 2020-01-07 03:06:49
问题 Created this macro to go through the entire worksheet and format each section as a table with a specific format. I'm trying to loop through the entire worksheet where and format each section as a table. Each section is separated by one blank row. Any ideas? Sub Macro8() Range("A3:B4").Select ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$3:$B$4"), , xlYes).Name = _ "Table6" Range("Table6[#All]").Select ActiveSheet.ListObjects("Table6").TableStyle = "TableStyleLight9" Selection.End(xlDown)

excel or excel VBA: how can I let user click on a cell and use it as a match result to an existing cell

寵の児 提交于 2020-01-07 03:06:25
问题 Wanted Attached is a snip picture of what I want to do. I have one column that lists all the options, and on the second column some items. For each item I want the user to physically select a cell and I can then use that selection as the match to the item. For example if the use click on "user1" then I need to populate cell D4 with text "user1". How can I achieve this? Thanks! 回答1: On the code for the worksheet from which you want to use the selection: Private Sub Worksheet_SelectionChange