I am new to visual basic, now only i am learning, pls give me solution and codes,
i need to define # rows and columns in excel based on input given by user in vb, i tried the
below code to define only row but i couldn't able to success it,
i using input box,FOR loop when user enter the row value in input box automatically the rows should be alloted
and after alloted rows fully fill with my name "MOHAN"
for example
if i give row value in input box 5 means then automatically 5 rows filled up with my name called MOHAN and
if i enter row value 80 then 80 rows filled with MOHAN
CODES:
Expand|Select|Wrap|Line Numbers
- Public oExcel As New Excel.Application
- Public oBook As Excel.Workbook
- Public oSheet As Excel.Worksheet
- Private Sub Command1_Click()
- Set oExcel = CreateObject("Excel.Application")
- Set oBook = oExcel.Workbooks.Add
- Set oSheet = oBook.Worksheets(1)
- Dim n As Integer
- Dim row As Integer
- n = InputBox("Enter how many rows you want", "Excel")
- For row = 0 To n
- Print "mohan"
- Next row
- oSheet.Range("A1").Value = "NAME"
- oExcel.Visible = True
- End Sub
excel rows based on my row value. Give me the right solution.