Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to copy a cell or a range of cells from one Excel spreadsheet to another Excel Spreadsheet with VS 2008 VB
    primarykey
    data
    text
    <p>I have created a GUI (the easy part) in VS 2008 VB that has two text boxes (one to select the target Excel file, and the other to select the destination Excel file). They both are accompanied by a browse button (uses OpenDialog to browse files select - ReadOnly). Additionally, I have two more text boxes which I have re-sized to midgets, to accommodate row/s and column/s (if a user wanted to copy cells 1-6 and columns A -D, they would simply enter 1-6 in the first text box, and A-D in the second text box). Lastly, I have a copy button at the bottom of the GUI, to be pressed once all fields have relevant data, as to copy the selected cell/s. I'm befuddled on how to copy a cell or a range of cells, by prompting the user for a number and a column and how to actually implement the logic of copying the cells. I've seen examples, but I have not successfully been able to apply them to my particular application. Any help is appreciated ... Thanks!</p> <p>VS 2008 VB Code: </p> <pre><code>Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk Dim strm As System.IO.Stream strm = OpenFileDialog1.OpenFile() TextBox1.Text = OpenFileDialog1.FileName.ToString() If Not (strm Is Nothing) Then strm.Close() End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim selectedFile As String = String.Empty If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then selectedFile = OpenFileDialog1.FileName End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim selectedFile As String = String.Empty If OpenFileDialog2.ShowDialog = Windows.Forms.DialogResult.OK Then selectedFile = OpenFileDialog2.FileName End If End Sub Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged End Sub Private Sub OpenFileDialog2_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk Dim strm As System.IO.Stream strm = OpenFileDialog2.OpenFile() TextBox2.Text = OpenFileDialog2.FileName.ToString() If Not (strm Is Nothing) Then strm.Close() End If End Sub Private Sub CopyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy_Btn.Click End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload