+ Reply to Thread
Results 1 to 2 of 2

Use VBA to insert text and format into Sheet2 while in Sheet1

  1. #1
    Registered User
    Join Date
    01-08-2015
    Location
    Dallas,Texas
    MS-Off Ver
    Excel 2010
    Posts
    2

    Use VBA to insert text and format into Sheet2 while in Sheet1

    In Sheet1 I am using a shape with assigned macro to open a form. I have a command button on the form that adds text and format to the form. It works fine when I am on Sheet2, but when I use the shape on Sheet1 to open the form and the button is pressed all the text and format go on Sheet1 instead of Sheet2.

    This is probably pretty simple, but I am new to vba and having some trouble figuring it out.

    Private Sub cmdAdditional_Click()

    Rows("10:10").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Rows("10:10").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Rows("10:10").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A12").Select
    ActiveCell.FormulaR1C1 = "Title"
    Range("A13").Select
    Sheet2.Range("B12").Value = txtTitle.Text
    ActiveCell.FormulaR1C1 = "Time"
    Range("B13").Select
    Sheet2.Range("A14").Value = txtTime.Text & ComboBox4.Value & "-" & txtTime1.Text & ComboBox5.Value
    ActiveCell.FormulaR1C1 = "Duration"
    Range("C13").Select
    Sheet2.Range("B14").Value = txtDuration.Text
    ActiveCell.FormulaR1C1 = "Host Name"
    Range("D13").Select
    Sheet2.Range("C14").Value = txtHost.Text
    ActiveCell.FormulaR1C1 = "Num of Participants"
    Range("E13").Select
    Sheet2.Range("D14").Value = txtParticipants.Text
    ActiveCell.FormulaR1C1 = "Vendor's Time"
    Range("F13").Select
    Sheet2.Range("E14").Value = txtS3Time.Text & ComboBox7.Value & "-" & txtS3Time1.Text & ComboBox6.Value
    ActiveCell.FormulaR1C1 = "Duration"
    Range("A12").Select
    Sheet2.Range("F14").Value = txtS3Duration.Text
    Selection.Font.Bold = True
    With Selection.Font
    .Name = "Arial"
    .Size = 12
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ThemeColor = xlThemeColorLight1
    .TintAndShade = 0
    .ThemeFont = xlThemeFontNone
    End With

  2. #2
    Registered User
    Join Date
    01-08-2015
    Location
    Dallas,Texas
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Use VBA to insert text and format into Sheet2 while in Sheet1

    ThisWorkbook.Sheets("Sheet2").Activate

    So that was super easy....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2013, 02:58 PM
  2. [SOLVED] Take Data From Column on Sheet1 and Insert Into Next Blank Row on Sheet2 Then Clear Sheet1
    By abutler911 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2013, 06:30 PM
  3. [SOLVED] Copy and Paste Entire Row from Sheet1->Sheet2 based on text string match in Sheet1 Row
    By dmlovic in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-17-2012, 08:42 AM
  4. Insert test/valle from sheet1 to sheet2 with a text statement.
    By bpope in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-19-2012, 05:22 AM
  5. Replies: 4
    Last Post: 08-30-2007, 07:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1