Need support with "VBA For Loop":

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi Currently my code looks like this.
But what i want is to start from J4 till J12 and then J3.
The range will be within J3:J12 however i want the loop to startfrom J4 and end in J3....


Thanks for advice.:)


Code:
[/FONT]
[FONT=Courier New]Option Explicit[/FONT]
[FONT=Courier New]Sub t()
Dim i As Range
For Each i In Range("j3:j12")
 If i <> "" Then
  Dim x As Integer
  Dim y As String
   x = i.Value
   y = i.Offset(0, -3).Value
   Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Select
   Selection.Resize(x, 1).Value = y
 End If
Next i
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Pedie,
you could try the following as the Macro is not too big

Code:
Option Explicit
Sub t()
Dim i As Range
For Each i In Range("j4:j12")
 If i <> "" Then
  Dim x As Integer
  Dim y As String
   x = i.Value
   y = i.Offset(0, -3).Value
   Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Select
   Selection.Resize(x, 1).Value = y
 End If
Next i
Call t1
End Sub
 
Sub t1()
Dim i As Range
For Each i In Range("j3")
 If i <> "" Then
  Dim x As Integer
  Dim y As String
   x = i.Value
   y = i.Offset(0, -3).Value
   Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Select
   Selection.Resize(x, 1).Value = y
 End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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