excel-vba

Loop through each cell in a range of cells when given a Range object

Let's say I have the following code: Sub TestRangeLoop() Dim rng As Range Set rng = Range("A1:A6") ''//Insert code to loop through rng here End Sub I want to be able to itereate through a collection of Range objects for each cell specified in rng. Conceptually, I'd like to do it like so: For Each rngCell As Range in rng...

VBA: How to display a cell value by its defined name?

I have already a defined name for a particular column in my worksheet. How to display a cell value by its defined name? I've tried these: Public Sub Test() Dim R As Range Set R = ThisWorkbook.Names("SomeName").RefersToRange MsgBox CStr(R.Value) End Sub but run-time error occured "Type Mismatch" (error code: 13). What...

Creating a macro to delete rows in Excel using VB

I need a code that will delete the enitre row when a specific name is typed into column A. So, for each row that has "Surgery" in column A, it needs to be deleted. Thanks. ...

Excel VBA or Function to extract Workbook name and data from workbook.

Is there any way to extract the workbook name, but then extract only a part of it. Any version of excel would be fine preferably 2003. For example "Help_TicketID123456788.xls" "Help_TicketID563565464.xls" ... So then I'd like to extract the ID numbers and put them into a column on a master worksheet in another workbook. Additi...

How to save a copy of an inactive worksheet - Excel 2003 vba

We have a piece of software that allows the user to run a report. The template for this report is an Excel workbook that exists on a network drive. The steps are: The user clicks "Generate Report" The software opens the template, populates the data, and closes the template, saving it in a specific directory. This is done "silently", ...

Starting javascript function due to URL Link in "Browser"

Hello guys, I'm using wininet to get the sourcecode from some homepages, afterwards I analyse that for some information. I use VB in Excel to do that. All of this is working fine, but now I want to get information from a special page. I have to open this page and click a link to go to the side with the wanted information. My problem ...

Excel summary of many excel files data into one report excel

Hi I have a number of excel files containing filled survery, now I would like to have one master document that would have summary result of each. Thus I imaging to have for each file a row input: name - address - some data... I would like to open each of the files, and copy the data from selected cells into my master file. I have ...

One RibbonX for multiple Excel 2007 workbooks

I have an Excel 2003 VBA solution I'm converting to Excel 2007. The solution had a large collection of menus that were used between multiple workbooks. I've created RibbonX to replicate this functionality, but now I'm to the point where I want to make my Ribbon show up on all these workbooks. How do I go about this? When I switch fro...

VBA: Copy paste without clipboard

Is there a way to do this as one line copy/paste without using the clipboard. copy one range - row to another sheet paste range - entire row. I need values, not formula. Sheets("Data").Select ActiveCell.EntireRow.Copy Sheets("TSP").Select ActiveCell.PasteSpecial Paste:=xlPasteValues ...

Select method of Range class failed via VBA

This is the code that I'm currently working with, and I'm getting this problem. I'm novice at Excel and I can't figure out what's wrong. Private Sub cmdRecord_Click() Sheets("BxWsn Simulation").Range("Result").Select //This is the line with the problem, as excel told me. Selection.Copy Sheets("Reslt Record").Select Sheets("R...

Book list - getting book details from amazon using Excel VBA barcode lookups

I have a barcode reader and bunch of books. For each of the books, I want to list the book name and the author in an Excel spreadsheet. My view is that some VBA code connecting to an Amazon web service would make this easier. My questions is - hasn't anyone done this before? Could you point me to the best example. ...

Need Help Using INDEX and MATCH with a Dynamic Named Range

Hi I have 2 ListBox's (Purchase_Select_Debtor) & (Purchase_Select_Quantity) on a Userform with a txtBox for Price (txtPrice). The Code uses Index and Match to return a result based on the Debtor and Quantity Selected. Below is my current code which works fine, but every time I add a new Debtor I have to alter the code to change the Ph...

save and close visio documents visual basic macro

I want to create a visio page, add some shapes, store it with a given filename and close it. Currently, always the object/template toolbar is active and thus stored under the given filename. What is the best way to store the current drawing? thanks Dim visioApp, visioPage as Object Set visioApp = CreateObject("visio.application") vi...

VBA: How to display an error message just like the standard error message which has a "Debug" button?

As usual, I create an error-handler using On Error Goto statement, there I put a few lines of cleaning codes and display the error message, but now I don't want to lose the comfortableness of the default handler which also point me to the exact line where the error has occured. How can I do that? Thanks in advance. ...

Importing data from SQL database in Excel 2003 VS Excel 2010 (VBA)

Hi, this is my first post, so I appologize if some of the formatting is not as it is usually expected. Please let me know if I've done something wrong. So, my company finally upgraded to MS Office 2010. Up untill now I've been working in 2003. I am a sql programmer, and I constantly create reports in excel that pull data from our dat...

How to make Selection.Find is locate an entire number instead of only the begging of it?

Hello guys, I have the following problem: in my macro, I select a range and try to locate a number within this selection. The problem is that if the number I am searching is 16 and there is a 160 followed by a 16 in the list, it finds the 160. How do I solve this?? Ideas? Range("AC7:AK12").Select Selection.Find(What:=numbe, After:=Activ...

VBA: How to make the current cursor in VBE jump to the line where the last error occured?

This is still related with my previous questions, VBA: How to display an error message just like the standard error message which has a “Debug” button? Now, I successfully make the current cursor in VBE jump to a particular procedure in VBE. I used Application.Goto to achieve this. However, what actually I want is to make the current cu...

Cut the row from a sheet and paste it to another if certain criteria is met

Hi I am trying to create a macro which cuts the selected row if it matches a certain criteria and has to paste it to a different sheet from the same workbook. Could Some please help me? ...

Issue with Find function against CSV files

I am have a few issues with trying to locate a number that has a length equal to or bigger thans 9 digits long. I have wrote this and if the number is less than 9 it picks it up otherwise it doesnt. The numbers are in a format like this 1013617518 Sub LoopThroughDirectory() Application.DisplayAlerts = False Dim Ifind As String, rngDa...

Copy email to the clipboard with Outlook VBA

How do I copy an email to the clipboard and then paste it into excel with the tables intact? I am using Outlook 2007 and I want to do the equivalent of "Click on email > Select All > Copy > Switch to Excel > Select Cell > Paste". I have the Excel Object Model pretty well figured out, but have no experience in Outlook other than...