+ Reply to Thread
Results 1 to 28 of 28

VBA referring to a different sheet, automatically fill cell based on content of other cell

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2013
    Location
    Buffalo, New York
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: VBA referring to a different sheet, automatically fill cell based on content of other

    I tried both of those suggestions and neither one worked for me. I think it's having a problem calling the sub if it's in a different sheet other than my itmof tab and vice versa, if the sub is in my itmof tab and I assign it to copy data macro, then it errors out a certain line in the sub...

    Thanks

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VBA referring to a different sheet, automatically fill cell based on content of other

    Try this code. It should work regardless of where you call it from.

    Sub Test()
        Dim bottomA As Integer
        bottomA = Sheets("itbof").Range("A" & Rows.Count).End(xlUp).Row
        Dim bottomL As Integer
        bottomL = Sheets("itbof").Range("L" & Rows.Count).End(xlUp).Row
        Dim rng1 As Range
        Dim rng2 As Range
        For Each rng1 In Sheets("itbof").Range("A2:A" & bottomA)
            If rng1 <> "" Then
                Cells(rng1.Row, 3).Value = "A"
                Cells(rng1.Row, 20).Value = "N"
            End If
        Next rng1
        
        For Each rng2 In Sheets("itbof").Range("L2:L" & bottomL)
            If rng2 <> "" Then
                Sheets("itbof").Cells(rng2.Row, 9).Value = Sheets("itbof").Cells(rng2.Row, 12).Value * 1.08
            End If
        Next rng2
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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