View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Newbie attempting VBA Scripting

This should get you started.


Sub movedata()

Worksheets.Add after:=Sheets(Sheets.Count)
Set newsht = ActiveSheet

OldRowCount = 1
NewRowCount = 1
With Worksheets("Old sheet")
Do While .Range("A" & OldRowCount) < ""
DataA = .Range("A" & OldRowCount)
DataB = .Range("B" & OldRowCount)

With newsht
.Range("B" & (NewRowCount + 2)) = DataA
.Range("C" & (NewRowCount + 3)) = DataB

OldRowCount = OldRowCount + 4
End With
OldRowCount = OldRowCount + 1
Loop
End With

End Sub


" wrote:

Hey all,

I am new on the block trying to create a macro which creates 4 new
lines with 21 columns from a set of source data. The macro will need
to count how many rows are in the source data (as each row is a
seperate entity) and store that count in a variable, X. Then it
should create 4 new rows in a new sheet and populate each cell with
various bits of information. The cells will be filled with simple
vlookups and just links to the source sheet, or just plain numbers and
text hardcoded (no links).

I know this was vague, but can anyone at least tell me how to do some
simple things like create a vlookup in a target cell, or a way to
count the number of rows in the source data, store it in a variable,
and then use that to create the appropriate number of 4-row entries in
the resulting worksheet, there being 4 new entires per 1 row from the
source.

Im basically trying to generate journal entries based upon source
data. I am trying to teach myself VBA through internet websites, but
figured i would tap this forum for some knowledge!

Thanks alot, in advance.

-pogster