+ Reply to Thread
Results 1 to 4 of 4

VBA - Values Not Getting Printed

Hybrid View

abhi_jain80 VBA - Values Not Getting... 06-17-2021, 08:45 AM
Greg M Re: VBA - Values Not Getting... 06-17-2021, 09:24 AM
abhi_jain80 Re: VBA - Values Not Getting... 06-18-2021, 04:05 PM
Greg M Re: VBA - Values Not Getting... 06-19-2021, 07:21 AM
  1. #1
    Registered User
    Join Date
    08-10-2016
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    67

    VBA - Values Not Getting Printed

    Hi folks,

    I got the vba script which is pulling out the values from multiple sheets against the unique items to the "Output" sheet. The code is working fine as per my requirement.

    I have added one more column "Range" in the "Output" sheet which is the difference between the columns E & F of the "Output" sheet. I have added the below code but unfortunately it's not printing the values in the "Output" sheet. Can anyone of you have a look please and suggest the mistake I am doing. Attaching the sample data for your reference. Thanks in advance...

      ' printing values in H column
      Worksheets("Output").Activate
      lastRow = Range("A" & Rows.Count).End(xlUp).Row
      For i = 2 To lastRow
      If Range("E" & i).Value = "" Or Range("F" & i).Value = "" Then
            Range("H" & i).Value = ""
      Else
            Range("H" & i).Value = Range("F" & i).Value - Range("E" & i).Value
      End If
      Next i
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA - Values Not Getting Printed

    Hi there,

    I haven't studied your code in detail, so I don't know what you're doing with the contents of the "v" array, but the highlighted lines are overwriting the output of the code that you posted:

    
    '''''''''''''''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''
      ' printing values in H column
      Worksheets("Output").Activate
      lastRow = Range("A" & Rows.Count).End(xlUp).Row
      For i = 2 To lastRow
      If Range("E" & i).Value = "" Or Range("F" & i).Value = "" Then
            Range("H" & i).Value = ""
      Else
            Range("H" & i).Value = Range("F" & i).Value - Range("E" & i).Value
      End If
      Next i
    '''''''''''''''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''
    
    
      With Worksheets("Output")
    
            .Cells(1, 1).CurrentRegion.Offset(1).Clear
            .Cells(2, 1).Resize(ndx, UBound(v, 2)).Value = v
    
            With .UsedRange
    
                .Columns("A:B").NumberFormat = "@"
                .Columns("C").NumberFormat = "#,##0"
                .Columns("D").NumberFormat = "d/m/yyyy"
                .Columns("E:H").NumberFormat = "$* #,##0.00"
    
            End With
    
    End With
    
    End Sub

    Thanks for posting the entire workbook instead of just the snippet of code, otherwise I wouldn't have been able to make this suggestion. I wish more posters would follow your good example!

    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    08-10-2016
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    67

    Re: VBA - Values Not Getting Printed

    Thanks Greg for identifying the issue. I got that resolved.

    Regards,
    Abhi

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA - Values Not Getting Printed

    Hi again,

    Many thanks for your feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ 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. If one worksheet is printed, a defined second one is supposed to be printed too
    By Postlki1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2013, 03:51 AM
  2. cells that do not get printed
    By rrlangly in forum Excel General
    Replies: 1
    Last Post: 03-23-2013, 04:27 PM
  3. Do not want a Column to be printed out
    By erimon in forum Excel General
    Replies: 4
    Last Post: 02-25-2013, 06:42 PM
  4. [SOLVED] Keep printing until all values in a column is printed out - Macro
    By itsmejan24 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-10-2012, 01:12 PM
  5. Run sub before sheet is printed?
    By proepert in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2010, 04:56 PM
  6. Replies: 3
    Last Post: 12-21-2006, 05:07 AM
  7. TOC of a printed spreadsheet
    By spiderstud in forum Excel General
    Replies: 2
    Last Post: 06-26-2006, 08:50 PM
  8. Which sheet will be printed?
    By Saniya in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2005, 05:05 AM

Tags for this Thread

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