+ Reply to Thread
Results 1 to 5 of 5

Creating a loop with a small formula

Hybrid View

  1. #1
    Registered User
    Join Date
    04-10-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    76

    Creating a loop with a small formula

    Hi,

    Im trying to get the following thing started but my loop doesn't succeed. I've got 3 columns. I need to place a formula in column C if A is empty.

    Example:

    A2 contains data so do nothing.
    A3 is empty do: C3=B3+B4.
    A4 contains data so do nothing.
    A5 contains data so do nothing.
    A6 contains data so do nothing.
    A7 is empty do: C7=B7+B8.

    this is what I've got so far:

    Dim rCell As Range
    
        If IsEmpty(rCell) Then
            ActiveCell.Offset(0, 3).Select
            ActiveCell.FormulaR1C1 = "=R[-1]C[-1]-RC[-1]"
        Else
    
        End If
    If you need an examplefile, just say so : )
    Last edited by flunzy; 03-13-2014 at 09:39 AM.

  2. #2
    Forum Contributor
    Join Date
    01-30-2013
    Location
    Wales
    MS-Off Ver
    Excel 2013
    Posts
    231

    Re: Creating a loop with a small formula

    If(A2="","",B3+b4)
    Click * below if this answer helped

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Creating a loop with a small formula

    Maybe:

    Sub flunzyaazz()
    Dim rcell As Range
    For Each rcell In Range("A2:A" & Range("A" & Rows.count).End(3)(1).Row)
        If IsEmpty(rcell) Then
            rcell.offset(, 3).FormulaR1C1 = "=R[-1]C[-1]-RC[-1]"
        End If
    Next rcell
    End Sub

  4. #4
    Registered User
    Join Date
    04-10-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Creating a loop with a small formula

    Thanks Chris for the option but I think that I will go with the one of mister Davis. With a small adjustment, it works perfect:

    Sub flunzyaazz()
    Dim rcell As Range
    For Each rcell In Range("A2:A" & Range("A" & Rows.Count).End(3)(1).Row)
        If IsEmpty(rcell) Then
            rcell.Offset(, 2).FormulaR1C1 = "=R[-1]C[-1]-RC[-1]"
        End If
    Next rcell
    End Sub
    Thanks for all the help : )

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Creating a loop with a small formula

    Glad it's working for you. If you have a satisfactory solution, please comply with Forum Rule No. 9.


    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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. Can't stop small loop
    By flunzy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2014, 06:43 AM
  2. Small Loop Problem
    By ericmax79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2013, 10:09 AM
  3. Replies: 0
    Last Post: 01-10-2012, 01:15 PM
  4. creating a small database
    By kamalthakur in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2008, 09:31 AM
  5. creating a small array from spreadsheet values/counts
    By tigpup. in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-07-2006, 09:55 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