Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am looking into VBA and I have a Question involving some code I have written. I have date in an excel worksheet such as

I am looking into VBA and I have a Question involving some code I have written.

I have date in an excel worksheet such as a persons name in A1..A2..A3 ect. with following information following them such as their date of Birth, height, weight in B1...C1...D1..ect.

My code so far asked for an input to search for a name in the list. My question is how can I have the code search for the persons name and then take their information and move it to another sheet such as sheet2 and then have a pop up displaying all the information.

This is my Code so Far.

Sub Uniform()

Application.ScreenUpdating = False

Dim i As Long Dim name As String Dim isfound As Boolean Dim count As Long Dim n As Double Dim WksNew As Excel.Worksheet Dim SrcRng As Range Dim myrange As Range

name = InputBox("Who are you looking for?") isfound = False count = Range("A1").EntireColumn("A").Rows.count i = 0

Do Until i = count i = i + 1 If Range("A1").Offset(i - 1, 0) = name Then Set myrange = ActiveCell.Offset(0, 1).End(xlToRight) With ThisWorkbook If .Worksheets(.Sheets.count).Range(myrange) = "" Then .Worksheets(.Sheets.count).Range(myrange).Resize(SrcRng.Rows.count, SrcRng.Columns.count).Value = SrcRng.Value Else Set WksNew = Worksheets.Add(after:=.Worksheets(.Sheets.count)) n = .Sheets.count .Worksheets(n).Range("A1").Resize(SrcRng.Rows.count, SrcRng.Columns.count).Value = SrcRng.Value End If End With

isfound = True End If Loop

If isfound = False Then MsgBox "Person Not Found"

End Sub

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago