Results 1 to 3 of 3

VBA code not printing in output cells

Threaded View

wabrown90 VBA code not printing in... 12-02-2020, 11:29 AM
torachan Re: VBA code not printing in... 12-02-2020, 11:51 AM
wabrown90 Re: VBA code not printing in... 12-02-2020, 12:57 PM
  1. #1
    Registered User
    Join Date
    10-23-2020
    Location
    USA
    MS-Off Ver
    365
    Posts
    16

    VBA code not printing in output cells

    Attempting to move information in the cells on the left into various cells over on the right. Not sure why the code is not printing properly. I have attached an example along with my code below.

    Sub Simulate()
    
    a = 4
    g = Sheet3.Cells(Rows.Count, "A").End(xlUp).Row
    
    Sheet3.Range("K4:BF101").ClearContents
    
    Dim away_team As String
    Dim home_team As String
    Dim away_ML As Integer
    Dim home_ML As Integer
    Dim away_line As Integer
    Dim home_line As Integer
    Dim loca As String
    
    For a = 4 To g
    
        away_team = Sheet3.Cells(a, 7).Value
        home_team = Sheet3.Cells(a, 8).Value
        away_ML = Sheet3.Cells(a, 4).Value
        home_ML = Sheet3.Cells(a, 5).Value
        home_line = Sheet3.Cells(a, 3).Value
        away_line = home_line * -1
        loca = Sheet3.Cells(a, 6).Value
        
        If loca = "H" Then
            
            Sheet3.Cells(a, 11).Value = Sheet3.Cells(a, 2).Value & "A"
            Sheet3.Cells(a + 1, 11).Value = Sheet3.Cells(a, 2).Value & "B"
            Sheet3.Cells(a, 12).Value = "A"
            Sheet3.Cells(a + 1, 12).Value = "H"
            Sheet3.Cells(a, 13).Value = away_line
            Sheet3.Cells(a + 1, 13).Value = home_line
            Sheet3.Cells(a, 14).Value = away_ML
            Sheet3.Cells(a + 1, 14).Value = home_ML
            Sheet3.Cells(a, 15).Value = away_team
            Sheet3.Cells(a + 1, 15).Value = home_team
            Sheet3.Cells(a, 16).Value = home_team
            Sheet3.Cells(a + 1, 16).Value = away_team
        
        ElseIf loca = "N" Then
        
            Sheet3.Cells(a, 11).Value = Sheet3.Cells(a, 2).Value + "A"
            Sheet3.Cells(a + 1, 11).Value = Sheet3.Cells(a, 2).Value + "B"
            Sheet3.Cells(a, 12).Value = "N"
            Sheet3.Cells(a + 1, 12).Value = "N"
            Sheet3.Cells(a, 13).Value = away_line
            Sheet3.Cells(a + 1, 13).Value = home_line
            Sheet3.Cells(a, 14).Value = away_ML
            Sheet3.Cells(a + 1, 14).Value = home_ML
            Sheet3.Cells(a, 15).Value = away_team
            Sheet3.Cells(a + 1, 15).Value = home_team
            Sheet3.Cells(a, 16).Value = home_team
            Sheet3.Cells(a + 1, 16).Value = away_team
            
        End If
             
        
    Next a
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. change date format in VBA code it means change output when printing cheque
    By keshavtale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2019, 06:06 AM
  2. Printing output using format from another sheet in the same workbook
    By Tapyr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2014, 06:53 AM
  3. [SOLVED] Comparing two cells for similarities and output a third cell (if C1 = B1, then output A1)
    By PERFECT777 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-26-2013, 12:37 AM
  4. [SOLVED] Code That Allows User to Select Two Cells and Get the Difference as an Output
    By jbwitty in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-08-2012, 05:20 PM
  5. Error in this simple code to output cell content if text is found in certain cells
    By pylauzier in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2011, 10:35 AM
  6. Printing problem, text printing outside the cells
    By alpine4133 in forum Excel General
    Replies: 3
    Last Post: 12-18-2010, 04:05 AM
  7. Range Comparisons and printing output
    By Ek0 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-14-2009, 11:21 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