Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My basic code for inputting data into 4 columns is below. The data is in 3
text documents (am249_1, am249_2, am249_3). This works. I need some code which will move down to the next blank cell in a column and insert the next data file after any data already present in the column. I need it so the data files can be opened in any order and that it will detect if data is already open. 'Inputbox asking for filename Dim Name Name = InputBox("Please enter the filename you would like to open:", , , 100) 'Opening files If Name = "am249_1" Then Open "C:\Documents and Settings\MC\Desktop\VBA assignment\am249_1.txt" For Input As #1 Linect = ActiveCell Do Until EOF(1) Input #1, t1, t2, t3, t4 Range("A1").Offset(Linect, 0) = t1 Range("B1").Offset(Linect, 0) = t2 Range("C1").Offset(Linect, 0) = t3 Range("D1").Offset(Linect, 0) = t4 Linect = Linect + 1 Loop Close #1 End If If Name = "am249_2" Then Open "C:\Documents and Settings\MC\Desktop\VBA assignment\am249_2.txt" For Input As #2 Linect = 0 Do Until EOF(2) Input #2, t1, t2, t3, t4 Range("A1").Offset(Linect, 0) = t1 Range("B1").Offset(Linect, 0) = t2 Range("C1").Offset(Linect, 0) = t3 Range("D1").Offset(Linect, 0) = t4 Linect = Linect + 1 Loop Close #2 End If If Name = "am249_3" Then Open "C:\Documents and Settings\MC\Desktop\VBA assignment\am249_3.txt" For Input As #3 Linect = 0 Do Until EOF(3) Input #3, t1, t2, t3, t4 Range("A1").Offset(Linect, 0) = t1 Range("B1").Offset(Linect, 0) = t2 Range("C1").Offset(Linect, 0) = t3 Range("D1").Offset(Linect, 0) = t4 Linect = Linect + 1 Loop Close #3 End If Thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() not sure I understand what you are needing exactly, but for entry into the empty cell at the end of a column, i like to use: Dim lRow as integer lRow = Activesheet.Cells(Rows.Count, 1).End(xlUp).Row Activesheet.cells(lRow + 1, 1).value = "blah" Don't know if that helps, but it's a routine I use rather religously in all manner of tasks ~ -- Ouka ------------------------------------------------------------------------ Ouka's Profile: http://www.excelforum.com/member.php...o&userid=23988 View this thread: http://www.excelforum.com/showthread...hreadid=502603 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
When inputting data in a cell, 20 becomes .20. How do I change? | Setting up and Configuration of Excel | |||
inputting data | Excel Discussion (Misc queries) | |||
Update a chart immediately after inputting data into data source | Charts and Charting in Excel | |||
Inputting Source Data - help please | Charts and Charting in Excel | |||
Format chart axis by inputting data in a cell | Charts and Charting in Excel |