VBA - Skip blank rows in loop and paste multiple rows in a simulation

Status
Not open for further replies.

jastisid

New Member
Joined
Aug 8, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hi there,

Please see attached the sample images. In the "Input Tab", I have assigned "ID" to each unique ID, and in the "Output Sheet", it runs all the simulations and prints the results. However, as you will notice for ID = "1", there are two unique IDs, but the VBA prints only the data relating to first unique ID. Any suggestions to print all unique ID data?

Also, when I mentioned skip blank rows, if you change the ID = "4", there is only one unique ID. Therefore, I want the VBA to skip the remaining rows and move to the next ID.

Any suggestions or change to the the below VBA code is much appreciated.

Thanks

VBA Code:
Sub Output()
  Application.ScreenUpdating = False
 
  [Output_Consol].ClearContents
 
  Dim Temp1 As Integer
  Dim i As Integer
 
  Temp1 = Range("ID").Value
 
  For i = 1 To Range("Num_Sims").Value
    If [Sample_Simulations].Value <> "" Then
      [Sample_Simulations].Copy
      Sheets("Output").Select
      Sheets("Output").Cells(13 + i, 2).Select
      Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End If
    Range("ID").Value = i
    Application.StatusBar = ([Num_Sims] - i)
  Next i

End Sub
Thanks


Simulations_Sample_Inputs.JPG


Sample_Simulations_Output.JPG
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
This is identical to your previous query, see the rules,
 
Upvote 0
Duplicate VBA - Skip blank cells in loop

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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