VBA Loop Range And Insert Values In New Column?

Mar 21, 2014

I built a Microsoft Access database for my church to track member information. I was able to import a lot of the needed information to create the records for each individual and household easily. What I can't do is import their offering donations until it is "Normalized." Which means that I need each row to be 1 record with the fields listed as the column headings. My church has a spreadsheet with several sheets one of which is named Input. I've attached the desensitized file for you to view/play with.

What I need to do is loop through the input sheet and find all the values in range B:4 to GN:387 that are greater than zero or not null (I believe they entered the default as zero so their other calculations would work). Then I need those values to be transferred to the column labeled Offering Amount on the ImporttoAccess sheet. Somehow I also need to define three variables associated with the cell that is contains a value greater than zero.

1. I need the row heading value for the envelope number (Column A of input sheet) which intersects with the amount

2. I need the column heading value (3 field merged) for the date (Row 1 of input sheet) which intersects with the amount

3. I need the column heading value (labeled: GenFund, WLA, or Missions) for the designation of the offering (Row 2 of input sheet) which intersects with the amount

Each of these I need to attach to the value offering amount and insert into their corresponding column fields for that record. I have entered 2 example rows of data into the ImporttoAccess sheet for you to see what I am after. I am sure it's possible since the data is there, But how to go about it.

View 4 Replies


ADVERTISEMENT

Macro Loop To Extract Specific Values And Min/Max Values From Column/Rows Range

Jun 3, 2009

Hi, I'm very new to writing Excel Macro's and wanted to know if I could do the following. Conceptually, I understand what I need done and think it should be fairly straightforward.

There's 2 main events in this loop (I hope that's the correct terminology):

Input 1) User defines the beginning cell to start the loop. In this case, A2.

Input 2) User defines the range of columns/rows to display. The formula for rows that I've thought of is 4r. So if a user wants 20 rows below cells A2, they simply input 5 for r. The number of columns is a constant 5. So if r=5, then I'd want the range to be A2:E22......

View 13 Replies View Related

Copy & Insert Range If Column Values Match

Mar 24, 2008

I have another little VBA macro problem that appears to be beyond my coding knowledge.

I have attached a small excel spreadsheet, with a macro recorded (CTRL-P) of what I'm trying to accomplish. Basically, If the data in column A matches a single entry in column F, I need to copy and insert the row (columns F-L) that matches.

View 4 Replies View Related

Insert Values From One Sheet To Another With A Loop

Oct 5, 2008

I need to insert values from a column in one sheet to another sheet with a Loop mentioned here.

(I have attached a sample workbook for your kind reference.)

IN STATEMENT SHEET, I NEED TO INSERT (IN col F) THE VALUES from Col A of NOS sheet.THE INSERTION SHOULD BE LOOPED AS MENTIONED HERE

i.e. First time, it should be 1 to 10
Second time it should be 2 to 10 and 1
Third time it should be 3 to 10 and 1, 2
Fourth time it should be 4 to 10 and 1,2,3
Fifth time it should be 5 to 10 and 1,2,3,4…. And so on, till the last row with a value in ColA.

THE VALUES IN Col A of NOS Sheet MAY BE CHANGED WHENEVER REQUIRED. There it is 1 to 10, but it may be Alphabets or any other words also.
Hence, whatever values in Col A of NOS sheet should be taken for looping.

View 8 Replies View Related

Excel 2013 :: Formula To Subtract 7th Column Values From Column Before 1st Loop?

Feb 21, 2014

I have a code that inserts a new column after every 7th column. I want to include a formula where every 7th column value is subtracted from the values present in the column before the 1st, or you can think of it as subtracting 7th column of the present group from the 7th column of the previous group. Example: The range of my data starts from col F, then

F (7th) New Column (G) H (1st) I (2nd) J (3rd) K (4th) L (5th) M (6th) N (7th) New Column (O) P (1st) Q (2nd) R (3rd)

So, New Column (O) = N - F
and the next New Column (W) = V-N ...

NOTE: Column G can be ignored.

I want to add a looping function to this so that it will continue to subtract for the other respective columns as well. How do I incorporate this into the following code?

[Code].....

I'm using Excel 2013.

View 2 Replies View Related

Insert Row (Based On Values In Range) With Sum Of Values For Other Columns

Apr 21, 2014

I have different reports, some have fifty transactions, others have thousands. My goal is to: Insert a new row every time the values in the "Account" column meet a certain criteria, AND THEN add the totals for the Debit and Credit Columns.

Let's say I start with a table that looks like this:

A
B
C
D
Dept
E
Account
T
F
F2
G
Debit
Credit
Total

33010

[Code] ....

I want to group the first four rows because Accounts 33010 and 33015 are in the same department. Same with 50050 and 500060. I want to then insert a row below the last row with "33015" as its Account #. And add the values for Debit and Credit. It'd look like this:

A
B
C
D
Dept
E
Account

[Code] .........

Honestly, I have tried everything. Running a Macros with Relative reference does not cut it.

View 8 Replies View Related

Loop Through Column Values?

Feb 5, 2009

What the easiest way of looping though the values in a column in a macro? How to you "call" the cells in the macro?

View 4 Replies View Related

Find Most Recent Date In Column Headings In A Range - Insert New Column And Heading

Apr 4, 2014

I have a 2 groups of column headings with a different month and year in each heading so

1st Group of columns range
Columns AJ through AX
Column Heading example "Expense Ratio February 2013......next Column over is "Expense Ratio March 2013"

2nd Group of columns range AY though CE
Column Heading example "Capital Balance February 2013......next Column over is "Capital Balance March 2013"

Each new month I need to add a new Expense Ratio column after the most recent expense ratio Column. (i.e. Find "Expense Ratio March 2013" and I need to add a column after that with heading "Expense Ratio April 2013"

Same thing for Capital Balance - add a new Capital Balance column after the most recent Capital Balance Column. (i.e. Find "Capital Balance March 2013" and I need to add a column after that for "Expense Ratio April 2013"

Because the ranges keep changing month over month, how do i do this.

View 4 Replies View Related

Loop Through Range Find Values?

Dec 6, 2013

I'm working with reports where I am given a list of used RFID tags which contain 13 alpha-numeric characters, and need to compare it against another list, in order to determine if any are matching. I'd like to be able to loop through one column of values to compare against the other, but unfortunately my VBA skills aren't that great..

View 5 Replies View Related

Loop Through Range & Use Cell Values In Variables

Aug 30, 2006

I have 2 worksheets. The first sheet has data of which some needs to be copied to a second worksheet. The trigger is a value found in column E. If a match is found, then a copy statement needs to be built. The values in F, G & H are the values to be used in the copy statement. The content of cell H may be numbers or letters or both.

What is the correct format of the copy statement?

Dimension all variables
Dim RowPointer As Long
Dim wbContrib As Workbook
Dim wbMaster As Workbook
Dim SheetName As String
Dim target_sheet As String
Dim target_cell As String
Dim Target_value As String
Dim CellAddr
'
' Initialize variables
Set RowPointer = 1
Set wbMaster = “Master.xls”
'
'******************************

View 9 Replies View Related

Assign Range & Interate Through & Insert Values

Jun 17, 2008

What I need to is create a VBA function with several parameters that reads data from an M x N range of rows and columns (matrix). I cannot just pick and choose certain cells within this range as the function goes into a loop through at least 200 cells in the 35 x 200 range. Obviously, I am here posting as I cannot get this function to work. I believe my troubles lie with reading this range into the function...

Application.Goto Reference:="range"
rangearray = Selection.Value

values(I, J) = rangearray(I + 1, J)

Do I need to set a function variable equal to that range, or do I do this another way? Basically, I need to have the ability to pick a given cell(m, n) out of the range and have my way with it in the function.

View 3 Replies View Related

Loop Criteria Based On Unique Values In A Column

Apr 3, 2009

i had a database from which i need to extract data from COlUMN B, select the

View 2 Replies View Related

Loop Through Cells On 1 Row Of Column Range

Mar 7, 2008

I am trying to create a loop in which the code "reads" ... lets say... cell F5. Determines if cell F5 = 1. if not, it moves on. only, instead of moving to cell F6, it moves to cell G5. so i need to add one to the column letter. How is this best achieved? having trouble with this. adding a letter to it concatinates them, and adding numbers, well its a mismatched type so that simply does not work.

View 3 Replies View Related

Lookup Values And Insert Column And Rows?

Feb 18, 2014

I have a table (Arrears) showing a list of customers with part numbers and quantities in arrears. A second table is a customer order table showing details of what needs to be shipped for a given date.

Based on these two tables, I would like to add a column to the Order table to show the values for arrears against the order quantity for the given date. In addition if there are no order requirements but there are arrears then insert a row to show the corresponding arrears.

see the attached spreadsheet for more details. This shows the two source tables (Arrears and Order) and the expected results showing the added column for arrears and the inserted rows.

View 6 Replies View Related

Insert 2 New Rows When Column A Values Change

Jan 12, 2009

Column A of my spreadsheet consists of Subcase 1000 to Subcase 1010 for example, with up to as many as 100 repetitions of each subcase in consecutive order. See Below:

Subcase 1000
Subcase 1000
.
.
.
Subcase 1001
Subcase 1001
.
.
.
Subcase 1002
Subcase 1002
.
.
etc

I would like a macro to find where Subcase 1000 finishes and Subcase 1001 begins and then insert 2 new rows between them. These 2 new rows have to be inserted between any change found in the column A field. The searching of Column A should start at Row 15. I have uploaded an example file. This file contains 2 sheets, 'Before Macro' and 'After Macro'. Hopefully it outlines what the outcome of the macro should look like.

View 4 Replies View Related

Insert New Rows When Column Values Change

Feb 5, 2009

I've posted this thread in http://www.excelforum.com/excel-prog...ml#post2038238 but since the thread has been solved, I think nobody would look into my problem, so I'm creating a new thread for the purpose.

My previous thread:

Hi there,

I'm looking for the same idea only that I wanted the macro to select the data in the cells selected. Based on the code given by StephenR above, I tried to do some modification but I don't know how to make it to start from the first cell of my selection, not from row 15 as R_S_6 wanted. The range selection can be in any column. Here are the code that I used:

View 14 Replies View Related

Insert Blank Column And Copy/paste Values

Apr 20, 2009

I'd like to have done is to have a blank column inserted between columns W and X(these values change so the VBA statement should reference the end of the columns) and the values that are now in column Y(April 17th values) pasted as values into the now empty column X. I would like to do this for tabs Ann-Sheet 2. I'm having a bit of trouble with setting up the loop that would go through the desired sheets.

View 4 Replies View Related

Loop To Increment Column Width Of Range Of Columns?

May 22, 2014

I'm trying to use the following loop to increment the column width of a range of columns thus:

Code:
NewWidth = 0
WidthIncrement = 0.5
For MyCount = 1 To 26
NewWidth = NewWidth + WidthIncrement
Cells(1, MyCount).EntireColumn.ColumnWidth = NewWidth
Next

If I set WidthIncrement to be an integer value, the code works correctly. If, however, I make it something like 0.1, all the column widths that the loop acts on are set to 0. I suspect it's something to do with how I'm declaring the NewWidth and WidthIncrement variables - they're currently set to Double. I know that I can have decimal values for column widths (e.g. 8.43)

View 5 Replies View Related

Search Column, Match And Insert Copied Range

Apr 30, 2007

I'm currently trying to insert the copy range of one worksheet to another. Let's say I have 3 worksheets, one main and two additional info sheet. I want to search column C in main worksheet for blank cell and use column F in the same row as the worksheet name which I want to copy from, then use column E from main worksheet as the keyword for the range I want to copy(range from column E to column Z). But when inserting, I want the keyword in main worksheet such as 'G' in the same row as blank cell to match the 'G' in copied worksheet. Because the 'G' in main worksheet is not in the same column for each row, I try to search the forum but can't find the inserting part. I also attach the example workbook.

View 3 Replies View Related

While Inserting Column Getting Error - Insert Method Of Range Class Failed

Jun 11, 2014

The below code was working absolutely fine yesterday but since this morning I am getting an error: "Insert method of range class failed" at the following line:

[Code].....

Here is the complete code.

[Code].....

I have googled it and didn't find any workable solution. My DataEntry sheet is unprotected.

View 8 Replies View Related

Loop Within A Loop (repeat The Loop Values)

Mar 31, 2008

With Sheets("regrade pharm_standalone")
For Each r In .Range("standaloneTerritory")
If r.Value = "X101" Then
r.EntireRow.Copy
Sheets("X101").Range("A1").End(xlDown).Offset(1).PasteSpecial xlPasteValues
End If
Next r
End With
-------------------
I need to repeat this loop for values from X101 to X151. In all cases, the sheet name is equal to the value I'm looking up (eg: value = X102 goes to sheet X102).

I have a named range called 'territories' that contains the list of X101 -> X152.

I'm hoping to make the code perform the loop for each of the territories without my having to copy & paste and change the 'X101' 51 times as this would seem a rather silly thing to do!

View 9 Replies View Related

Function To Sort A Range By The Values In A Specific Column And Return The Range

Mar 25, 2009

I was just recently forced to create my first UDF and after how well it worked I now am very interested in learning more. I am trying to create a function to sort a range by the values in a specific column and return the range. I know this should be really simple but for some reason my code dies whenever it gets to my inner-most loop. I need to use this in a larger function but for now this is my only question. I did find that Excel 2007 has built in Functions for this but my company still uses 2003.

My
Public Function SortRange(rngToSort As Range, valCol As Integer)
Dim Swapper As Variant
Dim i As Integer, _
j As Integer, _
k As Integer

For i = 1 To rngToSort.Rows.Count
For j = 1 To rngToSort.Rows.Count - i
If rngToSort(j + 1, valCol) < rngToSort(j, valCol) Then
For k = 1 To rngToSort.Columns.Count
Swapper = rngToSort(j, k)
rngToSort(j, k) = rngToSort(j + 1, k)
rngToSort(j + 1, k) = Swapper
Next k
End If
Next j
Next i
SortRange = rngToSort
End Function

View 9 Replies View Related

Do Loop Insert Row?

Sep 19, 2013

Is it possible to 'loop through a spreadsheet a7 - a5000 and where 'portfolio code :' is found in col A insert a row above it ?

View 2 Replies View Related

Loop Through A Spreadsheet Insert Into Another Wb Then Email

May 5, 2006

I am trying to create a macro that loops through a spreadsheet, copies data over to another workbook then emails the new document.

I have taken this code from an old macro that I found but cant seem to get it to work.
This is the code

Sub EmailAssessments()

Dim strTempName As String
Dim strForename As String
Dim strSurname As String
Dim strBookingNumber As String
Dim strReportingTo As String
Dim strBookingGivenBy As String
Dim strJobTitle As String
Dim dtmStartDate As Date
Dim strEndDate As String ''Need to use a string as there maybe no end date
Dim strDepartment As String
Dim strTierName As String
Dim r1 As Range ''For loop
Dim intNumberOfRows As Integer ''Count how many rows.........

View 9 Replies View Related

Insert Rows Within Loop Code

Apr 3, 2008

I have a requirement where I have to add a row with x columns using vba. this is the code I am using now

k = 17
prodetails = .GetFieldValue("Product Details")
sSeats = .GetFieldValue("Seats")
If isRecord Then
While isRecord
Sheets("Products").Rows(k).Insert Shift:=xlDown
Sheets("Products").Rows(k + 1).Insert Shift:=xlDown
Sheets("Products").Rows(k + 2).Insert Shift:=xlDown
ThisWorkbook.Sheets("Products"). Cells(k, Prod6Col) = prodetails
ThisWorkbook.Sheets("Products").Cells(k, Unit4Col) = sSeats
isRecord = .NextRecord()
Wend
End If

In this code I have declared Prod6Col and Unit4Col as constants. instead I need to use them as variables like in this modified code. However if i use this code, I get an object definition error.

k = 17
m = 20 (20th column)
l = 18 (18th column)
prodetails = .GetFieldValue("Product Details")
sSeats = .GetFieldValue("Seats")
If isRecord Then
While isRecord

View 4 Replies View Related

Excel 2010 :: Cell Insert In One Column To Insert In Other Columns?

Mar 23, 2012

I have a master data sheet with four columns, A, B, C and D

Column A has the primary data and B,C,D has dependent data values;

So when I insert a new cell in Column A with cells Shift Down, I want mandatorily new cells to be inserted in the same row in col B, C and D as well so that data integrity is maintained;

View 2 Replies View Related

Macro To Loop And Insert A Page-break

Feb 2, 2010

I have lurked and learned but now this is beyond me-Attached is a sample file - The tab Data is where I start the macro and it is the file( after I have cleaned it up) that I get once a week-I added Column K/L-Blank Count Sheet Format is where the macro puts the info- count sheet is what I want it to look like- Old version is how I used to present the sheets-using subtotals etc-See the print preview to see what old ver and sample look like--

This macro below starts in data and puts Column K / L on the blank and then fills them in. Field 1-5 is all one loc sequence -I have the macro going the first few steps what I have been pulling my hair out attempting to do is --If the part# stays the same keep putting the locations under each other-As I show on Count Sheet and when the part# changes put a page break in and start over again with the new part# and assorted info. The file I get each week to do this with will have from 150 to 200 part #'s. I need a page for each--Each part has from 1 to 10 location's ( The loc consists of Field1-5 alfa-numeric )

View 2 Replies View Related

Loop Through Customer List And Go To Sheet And Insert Data

Mar 18, 2014

I have created a excel workbook in which I use for keeping up with storage unit rent. I have a tenant list sheet and each tenant has a sheet on which I keep up with charges and credits. What I want is a macro the will loop thru each tenants sheet based on tenant list and insert data and go to the next sheet. I found this on the web:

[Code] ......

View 1 Replies View Related

Countdown Timer - Insert A Timer Into A Column Cell Range?

Nov 12, 2013

I am trying to insert a timer into a column cell range that will countdown in hours, mins, and sec, when I enter the time. example: when I enter the "time in hr,mins,sec" it will start to countdown to Zero automatically, when I hit the enter key.

View 3 Replies View Related

Build Range From Column And Row Values

Apr 24, 2008

I'm trying to copy a pivot table cell onto another worksheet that has a table with Month-Dates across the top in columns and left-most column has several cells, each with a named range. I get an application error with:

Sheets(shtSrc).rngSrc.Address.Copy _
Sheets(shtDest).Range(Sheets(shtDest).Range(rngDest).Row, Dt.Column)
shtSrc and shtDest are Strings passed in to Sub for worksheet name.
rngSrc is a Range passed in to Sub.
rngDest is the Named Range of the destination cell.

All of the values get passed in; I'm just not using the range properly I think.

I'm not married to what I've got so far. Basically, as long as the pivot data gets copied at the intersection of the correct Date (Column) and Row I'll be happy.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved