+ Reply to Thread
Results 1 to 5 of 5

VBA Loop Range and Insert Values in New Column

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA Loop Range and Insert Values in New Column

    I'm brand new to the forum. Normally, I can check the sites and find what I am looking for and haven't had to register... until now.
    Some background to my problem:

    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 I have no idea how to go about it.

    Thanks.
    Last edited by JBeaucaire; 03-21-2014 at 05:51 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Loop Range and Insert Values in New Column

    I don't see the sample output on the ImportToAccess sheet
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    03-21-2014
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA Loop Range and Insert Values in New Column

    Huh, don't I look dumb. I attached the file while writing the thread and then thought I should give a sample of my data needed. So, I thought I had removed the original attachment and reattached the new doc with the sample data. Apparently not. At any rate. I've reattached the document and also highlighted the field values in the input sheet that I sampled in the ImporttoAccess sheet.
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Loop Range and Insert Values in New Column

    This should do it. It takes a minute or so to run on all that data... it would run faster if you didn't have all those zeros in the empty cells, but it is what it is.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-21-2014
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA Loop Range and Insert Values in New Column

    Thank you so much! I copied your code and pasted into a command button and it works exactly the way I need it. I know how to manipulate controls and fields in Access with VBA but Excel is a bit different when referring to cells and ranges and such. So I had no idea where to start. (I am a landscaper by profession hoping to get into database administration and have been volunteering my time to the church to create this for them.) Thank you so much again.

    God Bless

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro to insert, copy and transpose values + loop
    By ddenicola in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2013, 09:31 AM
  2. Insert New row in another sheet and Loop based on values in certain cells
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-14-2013, 02:25 PM
  3. [SOLVED] Insert a different named range into VBA loop with each iteration
    By Dr_Gzus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2013, 04:57 PM
  4. Macro Loop to Extract Specific Values and Min/Max Values From Column/Rows Range
    By ExcelQuestFL in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-19-2010, 09:19 AM
  5. Insert values from one sheet to another with a Loop
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-11-2008, 09:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1