ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   help me out plz? (https://www.excelbanter.com/excel-worksheet-functions/32275-help-me-out-plz.html)

yousuf555

help me out plz?
 

hi ,

Using macros i am trying to make a database form.What i am doing is
i am putting data into primary excel sheet (INPUT.xls) and coverting it
into (Book1.xls)that is the other excel sheet.My problem is that i
have 20 rows in the primary excel sheet but when they are less than 20
(consider 18) the last two rows 19 and 20 still remain there.

Can anyone one help me out??


futher more can anyone tell me how to upload excel file into MS SQL
server


Thanks and Regards


THE CODE IS AS FOLLOWS




------------------------------------------------------------------------


Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Macro recorded 6/23/2005 by bits
'

'
Dim counter As Integer
Dim i As Integer
Dim n As Integer

n = 1
While Workbooks("input.xls").Worksheets("sheet1").Cells( n, 1) <
""
n = n + 1
Wend
Workbooks("file2.xls").Worksheets("sheet1").Range( "A1") =
Workbooks("input.xls").Worksheets("sheet1").Range( "A1")
Workbooks(" file2.xls").Worksheets("sheet1").Range("B1") =
Workbooks("input.xls").Worksheets("sheet1").Range( "A2")
Workbooks("file2.xls").Worksheets("sheet1").Range( "C1") = Workbooks("
input.xls").Worksheets("sheet1").Range("C2")
Workbooks("file2.xls").Worksheets("sheet1").Range( "D1") =
Workbooks("input.xls").Worksheets("sheet1").Range( "F2")
Workbooks("file2.xls").Worksheets("sheet1").Range( "E1") =
Workbooks("input.xls").Worksheets("sheet1").Range( "A3")

For counter = 2 To n - 4
Workbooks(" file2.xls").Worksheets("sheet1").Cells(counter, 1) =
Workbooks("input.xls").Worksheets("sheet1").Cells( 1, 2)
Workbooks("file2.xls").Worksheets("sheet1").Cells( counter, 2) =
Workbooks(" input.xls").Worksheets("sheet1").Cells(2, 2)
Workbooks("file2.xls").Worksheets("sheet1").Cells( counter, 5) =
Workbooks("input.xls").Worksheets("sheet1").Cells( 3, 2)
Next counter

For counter = 4 To n - 1
For i = 1 To 6
Workbooks("file2.xls").Worksheets("sheet1").Cells( counter - 3, i +
5).Value = Workbooks("input.xls").Worksheets("sheet1").Cells( counter,
i).Value
Next i
Next counter

Windows("file2.xls").Activate

End Sub
-------------------------------------------------------------------------


--
yousuf555
------------------------------------------------------------------------
yousuf555's Profile: http://www.msusenet.com/member.php?userid=2606
View this thread: http://www.msusenet.com/t-1870561229



All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com