Filling data in specific way.

Matrix335

New Member
Joined
Oct 5, 2015
Messages
27
[/CODE]
I am working on a project which requires to fill the data in specific way. After filling the 3 values in Col3, i should fill the data in Col4. After that i will start filling the data in the Col1 with new row and so on
Please check the following code.

Thank you.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Dim tAd As Variant
    tAd = Split(Target.Address, "$")
    Dim rowRemainder As Long
    rowRemainder = tAd(2) Mod 3
    
    If tAd(1) = "A" Then
        Range("B" & Target.Row).Activate
    ElseIf tAd(1) = "B" Then
        Range("C" & Target.Row).Activate
    ElseIf tAd(1) = "C" Then
        Range("D" & Target.Row).Activate
    ElseIf tAd(1) = "D" Then
          If rowRemainder = 1 Then
            Range("A" & Target.Row + 1).Activate
         Else
            Range("D" & Target.Row + 1).Activate
            
        End If
    End If
    
End Sub
 

Attachments

  • Filling data.jpg
    Filling data.jpg
    37 KB · Views: 9

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x&, y&, rT&, cT&
Dim sCell As Range
Set sCell = Range("A2") ' adjust actual start cell
rT = (Target.Row - sCell.Row) Mod 5 ' 3 is rows number each sequence
cT = (Target.Column - sCell.Column) Mod 6 ' 6 is columns number each sequence
If Intersect(Target, sCell.Resize(100000, 6)) Is Nothing Then Exit Sub
    Select Case cT
        Case Is < 3
            x = 0: y = 1
        Case Is < 5
            Select Case rT
                Case Is < 4
                x = 1: y = 0 'x,y is offset steps of target cell
                Case Else
                x = -4: y = 1
            End Select
        Case Else
             Select Case rT
                Case Is < 4
                x = 1: y = 0
                Case Else
                x = 1: y = -5
             End Select
   End Select
Target.Offset(x, y).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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