excel-vba

VBA/Excel: Tracing precedents to another sheet not working

我怕爱的太早我们不能终老 提交于 2020-01-07 05:07:06
问题 I recently started working with a friend's excel project, making macros. I was mostly doing this through the "Record Macro" function, as I am not knowledgeable in Visual Basic to code it myself, and there is not enough time to learn the language. All was going smoothly until I learned that ctrl-[ would not work to trace a cell's precedents inside of a macro because it just selected the cell that the first precedent was linked to, and would not change for future precedents. I looked up how to

VBA - CopyPasteCode with Sendkeys

廉价感情. 提交于 2020-01-07 05:05:13
问题 I'm using IDE in a excel workbook and trying to do the below code. Sub cpypaste() Range("E7").Select SendKeys ("^c"), True Application.Wait (Now + TimeValue("00:00:01")) Range("G7").Select SendKeys ("^v"), True End Sub Not that I do not know alternate ways of doing it, but just curious why this is not working. I've tried running this code with keyboard shortcut and cmdbutton as well. Any help will be greatly appreciated. 回答1: Using sendKeys is fecal at best. I assume you are starting the code

Create CSV file from Excel data for an each distinct value in a column?

大兔子大兔子 提交于 2020-01-07 05:04:28
问题 I have an excel with vendor codes(NUMBERS) as one of the columns. VENDORITEM| DESCRIPTION |PRICE|PRICEGROUP|VENDOR NUMBER|PRODUCT CATEGORY _______________________________ HNM36789 |30ML FLUID CLIN|50.00| B | 023445 |CMI TNG78934 |BACK PAD 3X5" |32.00| D | 000905 |CMI JPD12780 |FLEX DRILL GH |9.50 | R | 233590 |MISC I need to create an excel vba macro so that I can export the data for each vendor number into a csv file and give the csv filename something like 023445NEW, and specify a folder to

Open .csv file with Excel VBA

蹲街弑〆低调 提交于 2020-01-07 05:01:08
问题 I'm having a problem with this piece of my code in VBA and I can't figure out why it isn't working! I've tried another code to see if it was the loop that has the issue but the issue is specifically opening the files and not iterating through them. Sub fileloop(Path) Dim strFile As String, strPath As String Dim MyBook As Workbook strPath = Path '& "\*.csv" strFile = Dir(strPath & "\*.csv") MsgBox (strFile) While strFile <> "" 'placed another messagebox here to see if the strFile was the same

VBA Application.Index with array causes type mismatch error 13

孤者浪人 提交于 2020-01-07 05:00:08
问题 My macro throws a type mismatch error when I use Myarr= Application.Index(arr,0,1) I have tried adding option explicit and defining the variables as variants but nothing seems to work. The arr array is created from a CSV file and that contains 100000 rows and 11 columns. The arr looks fine when I check it in the watch window (I can see the values for each row and column) Here is the code: Sub ArrTest() Dim Myarr Dim Arr Dim wb As Workbook Set wb = Workbooks.Open("F:\People.csv") Arr = wb

How to open a new workbook and add images with VBA?

和自甴很熟 提交于 2020-01-07 04:40:27
问题 I'm trying to get a macro for Excel 2007to open a folder with a bunch of images in them. Then Create a new workbook and embed the images into it. Everything works if I comment out the line Sheet.Shapes.AddPicture FileName:=F, linktofile:=msoFalse, savewithdocument:=msoCTrue, Left:=cell.Left + 5, Top:=cell.Top + 5, Width:=560, Height:=310 If I uncomment that line I get "Run-time error '434': Object required" I've check that Sheet.Shapes is returning a Shapes object, it is but the Shapes object

VBA to save attachments (based on defined criteria) from an email with multiple accounts

梦想的初衷 提交于 2020-01-07 04:35:09
问题 Situation: I have a code that, given an input of sender email, will download all attachments from outlook email (if the sender is the one specified, it saves the .xls attachments). Problem 1: In my outlook, I have access to 2 accounts (lets say personal and public). I want to be able to select from which of those accounts the code should download the attachments. Question 1: Is it possible to do this kind of selection? From previous research I was able to find criteria regarding the type of

Performance issue in Dynamic Dropdown Search list in excel

谁说胖子不能爱 提交于 2020-01-07 04:34:08
问题 I have created dropdown list which gives suggestions from existing data (like google search). I have followed the steps mentioned in the link to get the expected result. I have changed the process to VBA Code since the column range that has data can increase in time (Formula will be inserted for a range dynamically when a new entry is added). Now the problem is since the column have more than 20 000 rows it takes more time to display the suggestions when a key is pressed. I need to get data

How do I delete a cell from Excel which contains less than 3 characters? I have only one column in sheet [closed]

核能气质少年 提交于 2020-01-07 04:30:14
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . The Excel file contains only cities. I want to delete the cells which contain less than three characters. How do I delete all the cells from Excel which contain less than 3 chars? 回答1: When you are in excel press Ctrl + F Click the "Replace" tab. In the box "Find what:" enter ??.

How can I detect the results of Conditional Formating using VBA?

随声附和 提交于 2020-01-07 04:29:07
问题 I have an excel file that has conditional formating set up to put a check or an x in a cell. How can I create an if statement that will detect which is in there without using the original conditioning formulas? 回答1: You can use this homemade function to check if condition is filled: http://www.cpearson.com/excel/CFColors.htm 来源: https://stackoverflow.com/questions/3049023/how-can-i-detect-the-results-of-conditional-formating-using-vba