VBA: Moving data range based on contents of specific cell in the range

OJMcGee

New Member
Joined
Jul 13, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm creating a 'to-do' list and currently have 6 columns.

Columns A:C are for 'to-do' items:
Column A: Task
Column B: Priority
Column C: Status

Columns D:F are for the 'doing' items
Column D: Task
Column E: Priority
Column F: Status

There are 20 rows.

When a 'to-do' task is updated to 'Doing', I would like for it to move over to the first available empty range in the 'Doing' section, i.e. in the image, A6:C6 would move to D6:F6 and A8:C8 would move to D7:F7, clearing them from the 'to-do' section.

Screenshot 2023-10-19 143351.png
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hello,

This should work:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C:C")) Is Nothing Then
    Application.EnableEvents = False
    If Target.Value = "Doing" Then
      Range("D" & Cells(Rows.Count, "D").End(xlUp).Row).Resize(, 3).Value = Target.Offset(, -2).Resize(, 3).Value
    End If
    Application.EnableEvents = True
  End If
End Sub
 
Upvote 0
Hello,

This should work:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C:C")) Is Nothing Then
    Application.EnableEvents = False
    If Target.Value = "Doing" Then
      Range("D" & Cells(Rows.Count, "D").End(xlUp).Row).Resize(, 3).Value = Target.Offset(, -2).Resize(, 3).Value
    End If
    Application.EnableEvents = True
  End If
End Sub
This is a great start, thank you.

I made a slight change so that it was filling the 'Doing' section, instead of overwriting everything:

Range("D" & Cells(Rows.Count, "D").End(xlUp).Row+1).Resize(, 3).Value = Target.Offset(, -2).Resize(, 3).Value

How can I now add to this so that after it adds to the 'Doing' section, it removes that entry from the 'To Do' section?
 
Upvote 0
Like this?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C:C")) Is Nothing Then
    Application.EnableEvents = False
    If Target.Value = "Doing" Then
      Range("D" & Cells(Rows.Count, "D").End(xlUp).Row).Offset(1).Resize(, 3).Value = Target.Offset(, -2).Resize(, 3).Value
      Target.Offset(, -2).Resize(, 3).Delete Shift:=xlUp
    End If
    Application.EnableEvents = True
  End If
End Sub
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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