macro help, please

  • Thread starter Thread starter spirosu
  • Start date Start date
S

spirosu

Need a marco to open up a message/text box where you're able to inpu
data...and then have that data transferred to another workbook onc
"ok" is clicked. On the new workbook it's transferred to, I'd like i
to know to parse on the next empty row in column A, and in column
next to it, to enter name of the workbook (file) it's coming from. Th
second workbook where the info. will be parsed to will be name
"individual" for example.

Plleeeeease help!!

P.S. - I bought a number of books on amazon.com last night dedicated t
vba...so hopefully I won't be posting for help for that much longer.

:
 
This may give you something to work with (I'm assuming the data goes into
"Sheet1" on the Individual workbook - change if necessary)

Sub test2()
Dim TargetWkSht As Worksheet
Dim LastCell As Range
Dim TargetRow As Long

On Error Resume Next
Set TargetWkSht = Workbooks("Individual.xls").Worksheets("Sheet1")

'Exit if target workbook not open, or target
'worksheet not found
If TargetWkSht Is Nothing Then
MsgBox "Target worksheet not found!"
Exit Sub
End If
On Error GoTo 0

With TargetWkSht
'Exit if Column A is full
If .Cells(.Rows.Count, 1) <> "" Then _
Exit Sub

'Find the last cell in Column A
'with data in it
Set LastCell = .Cells(.Rows.Count, 1).End(xlUp)

'Check to see if A1 is LastCell
'and does not contain data
'otherwise, select the next cell
'below it
If LastCell.Value = "" Then
TargetRow = 1
Else: TargetRow = LastCell.Row + 1
End If

'Input data
.Cells(TargetRow, 1).Value = _
InputBox("Input Data")
.Cells(TargetRow, 2).Value = _
ThisWorkbook.Name
End With

End Sub
 
JMB,

It's works brilliantly, it's exactly what I was looking for. I owe yo
a debt of gratitude! Thanks so much. I just pray that I can attai
your level of macro writing sooner than later. Thanks again.

best regards,
Spiro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top