Partially Solved VBA Code.

Status
Not open for further replies.

Thomas McLernon

New Member
Joined
Nov 22, 2021
Messages
4
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
By finding bits of code and stringing them together I got this row copy between sheets on specified criteria to work, and meet the requirements. Source data is formulas, and it needs to copy static data. (non reactionary data)

This all works except it is intended to copy over and retain (when criteria met) records cumulatively over time. This string copies new records over the top of existing records. I need code that will enable it to copy to the next blank row. The extent of my VBA experience is by trial and error.

Sub Macro1()

Dim c As Range
Dim NextRow As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet

Set NextRow = Range("A" & Sheets("Archived Schedules").UsedRange.Rows.Count + 1)
Set Source = ActiveWorkbook.Worksheets("Absence Scheduling")
Set Target = ActiveWorkbook.Worksheets("Archived Schedules")

j = 9

For Each c In Source.Range("E9:E1000")

If c.Value = "Company Term" Or c.Value = "Schedule Change" Or c.Value = "Self Term" Or c.Value = "AWOL Term" Then

Source.Rows(c.Row).Copy Target.Rows(j)

Target.Rows(j).Value = c.EntireRow.Value

If IsEmpty(Target) Then

j = j + 1

End If

End If
Next c

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Duplicate to: Transfer rows between worksheets when condition is met.

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,213,486
Messages
6,113,932
Members
448,533
Latest member
thietbibeboiwasaco

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