VBA value range for ActiveSheet instead of A1: B2

I'm a noob in VBA I have data range from Row1 to Row 226, trying to export it as csv file in comma delimited. Sub Comma() Dim r As Range: Set r = Range("A1:D4") Dim buffer As String, delimiter As String, c As Range Dim i As Long I want to set th

Rename the file where it was extracted

I've got a VBA macro that renames a file. I have the full path where this file exist but I want to rename this file independent from its location. Private Sub Workbook_Open() Dim sFileName As String, sNewFileName As String sFileName = "C:\Users\me\De

How can I get the name of a table from a range variable?

I dimmed the variable: Dim mainTableRange As Range Then gave it a value: Set mainTableRange = Range("tLedgerData") ' tLedgerData is an Excel table. Now I'm trying to get the name of the table (which is "tLedgerData") from the variable

update a column of value numbers to (value * 1.3)

I want to update a columns("B") of numbers to +30% I know I have solutions like a VBA "Loop" or an ADODB "UPDATE Query", But for some reason I can only use Excel Formula. So, I wrote VBA code like Columns("B").Formu

Delete cell in column B if cell A is empty - RANGE

Got a problem and looking for some advice. I've been using the below code for a while now in Excel, it clears the contents of column B if cell A is empty. It works great, but I now need it to work for a specific range (A6:B35). Any ideas? Private Sub

Separate data from one cell and copy to another column

I have a column named Description, with a description of expenses and an expense date. The file I am getting it from does not have the correct expense date. I want to separate the data and copy the date to the expense date column and paste the remain

VBA: Find the last row in a fixed number of beaches

I tried for a few hours to search and look for a possible answer. I am about ready to give up. I haven't been able to find someone with a scenario quite like the one I am asking, maybe I overlooked it. I want to find the last row in a specific range.

Download my VBA user form

I made a function which should convert the gross income to net income. In this case the gross income would be provided in the cell B1. The function works as follow: Start the function and select the input in the function so in this case its B1: =Gros

How to write VBA Excel 2010 in Visual Studio 2015 Community?

I have been programming with Excel 2010 VBA for a while but I am a newbie with Visual Studio 2015 Community. I had installed it when it was announced this year and found the workflow features for developers in regards agile/scrum methodology amazing

Create a new column in Excel based on the previous column data

Just a disclaimer: I have limited experience with Excel and sql... I'm basically a noob, so bear with me. I have a big Excel spreadsheet that is sent to me daily that I would like to manipulate. I would like to add a couple columns that create values

Copy Excel lines to empty cells

I am trying to copy rows that contain data (in cells A, B, C, D) down into the same cells (in the different rows) if the cells are blank. So basically copying the data in the above cells if the preceding cells are empty. The code I have is as follows

How to import Excel data to mysql?

I have an excel sheet that contains many fields. I have a database that contains many tables which are linked to 1 another. The fields that excel sheet contains get inserted to multiple tables which are linked to 1 another. Eg sample.xls or .xlsx id

Copy a specific line to another workbook based on a cell value

I want to copy row(A:E), row(F:AH), and row(AL)from the active workbook to row(A:E), row(G:AI), row(AJ) of another workbook. Here's the code that I'm working on. I saw it here and just edited it. Dim wb1 As Workbook, wb2 As Workbook Dim ws1 As Worksh

Evaluate a relative reference of VBA against a known cell

I'm using the trick described here - !A1 - to get the the range of cells up to and including the current one (typically for a Rows() function). This works great for day to day usage, and eliminates a lot of errors that I get when moving ranges around

Workbook instance is active even after manual closing

I am adding workbook to the workbooks programmatically thru macro. when i close the newly created workbook manually,then try to run the code then i am facing issue like "Automation Error" or "WorkBook_ Activation failed" . Please how c

Browse each column in a row by name in a table

I have a table with seven columns containing dates. Each column has dates that are assigned using a different formula for each column. My ultimate goal is to compare the dates against today, and if it's within a certain amount of time, to fire off an

loop through sheets specified in VBA

I am trying to use a bit of code I found here For Each Function, to loop through specifically named worksheets to loop through specified sheets in a workbook, run a small amount of code and move to next sheet. Sub LoopThroughSheets() Dim Assets As Wo

How to add a VBA code to remove Excel duplicates

This question already has an answer here: RemoveDuplicates gives 1004 error 1 answer I've 2 sheets, for example (sheet 1 and 2). I'll copy some data from sheet 2 to sheet 1. After that i need to remove duplicated values from a column. My code is: Sub

Display hard-coded formulas after running the macro

Is there a way to display formulas by clicking into the cell? I wrote multiple hardcoded formulas into vba and after I run the macro, I only get values in the cells. I want it so that after the macro runs, I can still view the formula in the cells. T

VBA find the positional coordinates of the found value

I have this simple macro that goes to the location where a value is. Sub dkdk() Dim dk As String Dim rng dk = "Document Type" If Trim(dk) <> "" Then With Sheets(1).Range("1:10") Set rng = .Find(dk, .Cells(.Cells.Count),

Write the VBA dictionary to a text file

I have the twitter search api results stored as an Excel VBA Dictionary. I would like to write the dictionary to a text file. How do I do that?Consider: Sub Lexicon() Dim d As Dictionary Set d = New Dictionary d.Add "james", 1 d.Add "willia

Error while using Excel's User Defined function in Matlab

Possible Duplicate: Excel Addin Error #NAME? I think it is a follow-up query to my earlier reported issue concerning User defined function in Excel. I am able to use the function in Excel when used Manually, but when I write to an excel file using Ma

Control a web browser using Excel VBA

I have been assigned the task of automating a web based task ( for a HTTPS website). The users currently are filling in the Excel sheet with the data, they now want to automate excel in such a way that it directly controls the browser and fills in th

Recommended IDE for VBA

Is there a recommended IDE for developing Excel VBA macros that provides reasonable error reporting and code completion? Currently, I'm using "Microsoft Visual Basic For Application" IDE which comes with Excel 2007, but so far, it is less than i

Creating and naming spreadsheets in Excel VBA

I have some very simple code that adds a new Worksheet, after the current worksheets, to an Excel document, and then changes its name to one entered in a text box on a userform. Works fine on a new workbook, however in a workbook that has a number of