rhino4eva
Active Member
- Joined
- Apr 1, 2009
- Messages
- 262
- Office Version
- 2010
- Platform
- Windows
So i have been using a vba code to fill an 12 columnsX 8 rows into columns of 8 form a list of 96 of one column
i need to modify the code to fill the the same 12 column x 8 Rows but now i need to fill horizontally into rows of 12
and each number will require 2 wells
eg
1
2
3
to become 1 1 2 2 3 3
the code is this
Sub RUNFILL()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim rFound As Range
Set WS1 = Sheets("DATA")
Set WS2 = Sheets("BackingSheet")
For X = 3 To 99
With WS2.Range("c22:f45")
On Error Resume Next
target = WS1.Range("b" & X).Value
On Error Resume Next
Set rFound = .Find("*", SearchDirection=xlPrevious,SearchOrder=xl,ByColumns,L ookIn:xlValues)
On Error Goto 0
If InStr(target, "Probationary") <> sBPPdetect Then
ElseIf rFound Is Nothing Then
.Cells(1).Value = target
ElseIf Intersect(rFound, .Cells(.Rows.Count, .Columns.Count)) Is Nothing Then
If rFound.Row < .Rows(.Rows.Count).Row Then
rFound.Offset(1, 0).Value = target
Else
rFound.Offset(-.Rows.Count + 1, 1).Value = target
End If
End If
End With
Next X
i need to modify the code to fill the the same 12 column x 8 Rows but now i need to fill horizontally into rows of 12
and each number will require 2 wells
eg
1
2
3
to become 1 1 2 2 3 3
the code is this
Sub RUNFILL()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim rFound As Range
Set WS1 = Sheets("DATA")
Set WS2 = Sheets("BackingSheet")
For X = 3 To 99
With WS2.Range("c22:f45")
On Error Resume Next
target = WS1.Range("b" & X).Value
On Error Resume Next
Set rFound = .Find("*", SearchDirection=xlPrevious,SearchOrder=xl,ByColumns,L ookIn:xlValues)
On Error Goto 0
If InStr(target, "Probationary") <> sBPPdetect Then
ElseIf rFound Is Nothing Then
.Cells(1).Value = target
ElseIf Intersect(rFound, .Cells(.Rows.Count, .Columns.Count)) Is Nothing Then
If rFound.Row < .Rows(.Rows.Count).Row Then
rFound.Offset(1, 0).Value = target
Else
rFound.Offset(-.Rows.Count + 1, 1).Value = target
End If
End If
End With
Next X