+ Reply to Thread
Results 1 to 9 of 9

Trying to apply formula to each column and row in every sheet

  1. #1
    Registered User
    Join Date
    02-20-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    19

    Trying to apply formula to each column and row in every sheet

    Hello,

    I am new to this forum so I apologize if i break and rules or do not provide enough information. I am working on developing a pretty simple code to go through variable amounts of data in both rows and columns and for a variable(1 to x) amount of sheets I have pasted my code so far down below. It is pretty basic so far, a few special notes though: 1) I am getting my data through a API feed that I have access to, 2) the name of the data set I pull in always shows up in A1, 3) the first piece of data (after headers and time stamps etc) always shows up at B7.

    I have two additional loops that I havent filled out ( or know what formulas i want to put in there yet) I did some research online and found some people saying that I didn't need the loops to get excel to loop the formula for each row and column, and that excel was smart enough on its own to do this inside the first for loop can someone confirm this for me?

    An example excel format coming from the API is attached for reference, a key thing that this has to be able to do is detect how many rows and columns each sheet has and apply the formulas at the end of them respectively.

    code so far:
    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by Plux; 02-20-2018 at 04:18 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Trying to apply formula to each column and row in every sheet

    missing an = symbol.
    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    02-20-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    19

    Re: Trying to apply formula to each column and row in every sheet

    thank you for that, With that fix the formula isn't doing what i would like it to do. I will admit i had to do some research online to attempt to write that line and it doesn't seem to be quite right. Any suggestions on how to write that line to get it to look at each worksheet as it flips through them and look at each row? I tried running it as the activeworksheets(I).range but that didn't work. Any tips much appreciated!

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Trying to apply formula to each column and row in every sheet

    See how this works for you

    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 02-20-2018 at 09:03 PM.

  5. #5
    Registered User
    Join Date
    02-20-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    19

    Re: Trying to apply formula to each column and row in every sheet

    Thanks JLGWhiz that worked for the average function. I will see if i can replicate for other formulas i want to use. Thanks so much!

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Trying to apply formula to each column and row in every sheet

    Quote Originally Posted by Plux View Post
    Thanks JLGWhiz that worked for the average function. I will see if i can replicate for other formulas i want to use. Thanks so much!
    You are welcome,
    regards, JLG

  7. #7
    Registered User
    Join Date
    02-20-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    19

    Re: Trying to apply formula to each column and row in every sheet

    Hi JLG,
    The code was working fine yesterday. Towards the end of the day and this morning it stopped working and I am now getting autofill method range of class failed run time error 1004. When I walk through the code it looks like the row_count and column_count functions are getting stuck at 7 and 2 respectively regardless of how many rows and columns there are in the worksheet. Any thoughts on what might of caused this to happen?

  8. #8
    Registered User
    Join Date
    02-20-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    19

    Re: Trying to apply formula to each column and row in every sheet

    for a little more troubleshooting help, when I use my original code to count rows and columns that does give me the correct row and column count

  9. #9
    Registered User
    Join Date
    02-20-2018
    Location
    United States
    MS-Off Ver
    2016
    Posts
    19

    Re: Trying to apply formula to each column and row in every sheet

    Sorry for the spam updates,
    It looks like it has something to do with being in my personal macros instead of in the macros on the worksheet i am working on. When i take the code and place it into the "thisworksheet" section it works fine. Ideally id like to have it in my personal macros so i can apply it to any excel i open or data i pull in from the API i am working with. Is there a way to make it capable of doing this?

+ 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. VBA to lookup text in one column then apply formula to number in another column
    By Evan69 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2017, 02:01 AM
  2. [SOLVED] Apply VBA Script based on Text in one column and apply a formula in another column
    By vvincent in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2016, 09:19 PM
  3. apply a formula to a whole column
    By abelle82 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-04-2016, 03:28 PM
  4. Apply formula to all cells in column C for all populated cell in column A
    By mrplow911 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-18-2014, 11:19 AM
  5. Apply a formula in a new column that pulls unique values from another column
    By shepherdc2814 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-24-2014, 10:04 PM
  6. Replies: 1
    Last Post: 06-21-2013, 01:41 AM
  7. Apply Formula to a Whole Column
    By somebody123 in forum Excel General
    Replies: 18
    Last Post: 11-26-2008, 05:37 PM

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