Not sure if VBA question or excel expert question

KimJ

New member
Joined
May 1, 2020
Messages
3
Reaction score
0
Points
0
Excel Version(s)
Excel 2016
Newbie to this site, please be patient with me if i'm posting incorrectly to this forum. Hoping to get some help with this.

Trying to move rows of data into other worksheets based on a common column identifier. Is it a macro, an excel formula or VBA?

type of virus intake date test result action sign off etc. etc. etc.
corona
corona
sars
aids
sars
corona
etc.etc.

masterworksheet separate Corona worksheet separate Sars worksheet separate Aids worksheet which collect the rows of information from the master worksheet
 
.
Code:
Option Explicit

Sub CopyOwnTab()
'ClrRng     '<--- uncomment this term if you want the sheets to display only the current data from Sheet1
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
On Error Resume Next
Lastrow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Dim ans As String
    For i = 2 To Lastrow
    ans = Sheets("Sheet1").Cells(i, 1).Value
        Sheets("Sheet1").Cells(i, 1).EntireRow.Copy Sheets(ans).Rows(Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1)
    Next
Sheets("Sheet1").Range("A1").Select
Application.ScreenUpdating = True
End Sub




Sub ClrRng()


Dim rs As Worksheet


For Each rs In ThisWorkbook.Worksheets
   If rs.Name <> "Sheet1" Then
        rs.Range("A2:N100").ClearContents   '<-- Edit range to clear here
   End If
Next rs


End Sub
 

Attachments

  • Virus Database.xlsm
    20.8 KB · Views: 10
You are amazing!!! Thank you so much for your help! Other than using the program, there's no quick excel formula that can replicate the same thing, right? Many thanks.
 
I would guess there is a formula that could be used but, honestly, formulas are not my strong point. I most often stick
with the macros.

Sorry.
 
Back
Top