Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems in Visual Basic Editior, In search of a command

Overview of what I have done:

Using VB Editor I wrote instructions for copying data entries from m
primary worksheet to move my second sheet in my desired format. i.e
it is not an exact duplicate of my first worksheet.

* Basically 1 line of data being entered in my first sheet is copie
into four lines on my second sheet.


The Problem:

I am trying to write a command that will recognize the instructions
wrote as variable so I can make this format repeat as I continue t
make entries in my first worksheet over time.

I know that the command will have to recognize that the instructions
wrote will act in increments of four and I have tinkered with command
but have been unsuccessful. Any suggestions or tips would be ver
gratefully appreciated.

Below is a sample of the commands I wrote. The data from Sheet 1 is
single row of inputs that copy into four lines on the second sheet as
want them.

Sub Duplicate1()

Range("L2").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-0]C"
Range("L3").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-1]C"
Range("L4").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-2]C"
Range("L5").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-3]C"
Range("L5").Select

Range("M2").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-0]C"
Range("M3").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-1]C"
Range("M4").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-2]C"
Range("M5").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-3]C"
Range("M5").Select


End

For Example: On Sheet 1:

L = Quantity, and will copy to L on Sheet 2 but into four rows
M = Price, and will copy to M on Sheet 2 but into four rows


Matt S

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problems in Visual Basic Editior, In search of a command

do you want to accumulate values or will your enteries always be in L2:L5
and M2:M5

If the latter and entries always made in L2 and M2, once the formulas are
entered as you code does, the second sheet would always display 4 copies of
the current values.

Assume you are not always entering your values in sheet Entry in L2 and M2.
If not will you want both the entry of data and duplication of 4 instances
of each value to accumulate as well (entries progress down column L and M in
Entry and 4 copies progress down the second sheet).

Clarify and perhaps you can get answer that is consistent with your need.

--
Regards,
Tom Ogilvy


"Matt G " wrote in message
...
Overview of what I have done:

Using VB Editor I wrote instructions for copying data entries from my
primary worksheet to move my second sheet in my desired format. i.e.
it is not an exact duplicate of my first worksheet.

* Basically 1 line of data being entered in my first sheet is copied
into four lines on my second sheet.


The Problem:

I am trying to write a command that will recognize the instructions I
wrote as variable so I can make this format repeat as I continue to
make entries in my first worksheet over time.

I know that the command will have to recognize that the instructions I
wrote will act in increments of four and I have tinkered with commands
but have been unsuccessful. Any suggestions or tips would be very
gratefully appreciated.

Below is a sample of the commands I wrote. The data from Sheet 1 is a
single row of inputs that copy into four lines on the second sheet as I
want them.

Sub Duplicate1()

Range("L2").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-0]C"
Range("L3").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-1]C"
Range("L4").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-2]C"
Range("L5").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-3]C"
Range("L5").Select

Range("M2").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-0]C"
Range("M3").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-1]C"
Range("M4").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-2]C"
Range("M5").Select
ActiveCell.FormulaR1C1 = "=Entry!R[-3]C"
Range("M5").Select


End

For Example: On Sheet 1:

L = Quantity, and will copy to L on Sheet 2 but into four rows
M = Price, and will copy to M on Sheet 2 but into four rows


Matt SF


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems in Visual Basic Editior, In search of a command

Hi Tom, Thanks for your response. You were able to articulate what
was trying to in my original post.

My desired reult is to have my entries from Sheet 1 progress dow
columns L and M duplicating in 4 instances

I have been trying variations of a vlookup to make this work a fe
minutes ago and still have had no success. I will keep trying.

Thanks again,
Mat

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problems in Visual Basic Editior, In search of a command

You don't totally clarify, but I will make an assumption. I will assume you
make entries in L2 and M2 and when you change the value in M2, you want the
values in L2 and M2 recorded as constants (4 times) in sheet2

right click on sheet1 and paste in code like this

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

If Target.Count 1 Then Exit Sub
If Target.Address = "$M$2" Then
With Worksheets("Sheet2")
If IsEmpty(.Range("L2")) Then
Set rng = .Range("L2")
Else
Set rng = .Cells(Rows.Count, "L").End(xlUp)(2)
End If
End With
rng.Resize(4, 1).Value = Me.Range("L2")
rng.Offset(0, 1).Resize(4, 1) = Target
End If

End Sub


Always enter in L2 first, then M2

--
Regards,
Tom Ogilvy


"Matt G " wrote in message
...
Hi Tom, Thanks for your response. You were able to articulate what I
was trying to in my original post.

My desired reult is to have my entries from Sheet 1 progress down
columns L and M duplicating in 4 instances

I have been trying variations of a vlookup to make this work a few
minutes ago and still have had no success. I will keep trying.

Thanks again,
Matt


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with excel and visual basic for applications Edward Letendre Excel Discussion (Misc queries) 0 September 24th 09 11:03 PM
Help me please understand this Visual Basic command Steve Excel Discussion (Misc queries) 1 September 16th 08 06:14 PM
Visual basic editior Stan Halls Excel Worksheet Functions 3 September 14th 07 12:24 PM
VISUAL BASIC COMMAND TO MOVE CURSER DOWN ONE CELL Moving Problem! Excel Worksheet Functions 2 December 19th 06 08:00 AM
visual basic command in a cell?? konky Excel Programming 1 August 26th 03 06:33 PM


All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"