modification needed - stumped!

erutherford

Active Member
Joined
Dec 19, 2016
Messages
449
The code takes entry information ("entries") and prefills another worksheet ("Final_Wash") with that data. Works flawless.
I would like to modify the code so that it looks at the "entries" worksheet, column I and only selects those records with a "W".
Usually pretty good at modifying existing code, but stumped on this one. My guess is the modification is in the "create array from range"



Code:
<code>
Private Sub CommandButton8_Click() 'Wash Print Final
Dim EntriesRange As Range, BasicRange As Range
    Dim PrintCell As Range, cell As Range
    Dim Data As Variant
    Dim i As Integer
    Dim msg
    
       
            
   msg = MsgBox("Confirm Print all records?", vbYesNo, "Confirm")
        If msg = vbYes Then
    With ThisWorkbook
'basic sheet data entry range
        Set BasicRange = .Worksheets("Final_Wash").Range("B2,D2,E2,B5,C5,D5,E5,G5,J5")
        With .Worksheets("Entries")
            Set EntriesRange = .Range(.Range("A3"), .Range("A" & .Rows.Count).End(xlUp))
        End With
    End With
    
    For Each cell In EntriesRange.Cells
'create array from range
        Data = Application.Transpose(cell.Resize(1, 9).Value2)
        i = 1
'array elements to non-contiguous range
        For Each PrintCell In BasicRange.Cells
            PrintCell.Value = Data(i, 1)
'increment to next array element
            i = i + 1
        Next PrintCell
        
'print out record
      BasicRange.Parent.PrintPreview
    Next cell
    ElseIf msg = vbNo Then

            End If
    Exit Sub
End Sub
</code>
 
Last edited by a moderator:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How about
Code:
    For Each cell In EntriesRange.Cells
      If cell.Offset(, 8).Value = "W" Then
   'create array from range
           Data = Application.Transpose(cell.Resize(1, 9).Value2)
           i = 1
   'array elements to non-contiguous range
           For Each PrintCell In BasicRange.Cells
               PrintCell.Value = Data(i, 1)
   'increment to next array element
               i = i + 1
           Next PrintCell
           
   'print out record
         BasicRange.Parent.PrintPreview
      End If
    Next cell
 
Upvote 0
How about
Code:
Private Sub CommandButton8_Click() 'Wash Print Final
Dim EntriesRange As Range, BasicRange As Range
    Dim PrintCell As Range, cell As Range
    Dim Data As Variant
    Dim i As Integer
    Dim msg
    
       
            
   msg = MsgBox("Confirm Print all records?", vbYesNo, "Confirm")
        If msg = vbYes Then
    With ThisWorkbook
'basic sheet data entry range
        Set BasicRange = .Worksheets("Final_Wash").Range("B2,D2,E2,B5,C5,D5,E5,G5,J5")
        With .Worksheets("Entries")
            Set EntriesRange = .Range(.Range("A3"), .Range("A" & .Rows.Count).End(xlUp))
        End With
    End With
    
   For Each cell In EntriesRange.Cells
      If cell.Offset(, 8).Value = "W" Then
   'create array from range
           Data = Application.Transpose(cell.Resize(1, 9).Value2)
           i = 1
   'array elements to non-contiguous range
           For Each PrintCell In BasicRange.Cells
               PrintCell.Value = Data(i, 1)
   'increment to next array element
               i = i + 1
           Next PrintCell
           
   'print out record
         BasicRange.Parent.PrintPreview
      End If
    Next cell
    End If
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top