I need to align two rows of data containing date and time of equipment
readings. One is taken every second and one every 3 seconds ....
A B C
D
02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
02/01/05 13:22:02 <data> 02/01/05 13:22:04 <data>
02/01/05 13:22:03 <data> 02/01/05 13:22:07 <data>
02/01/05 13:22:04 <data> 02/01/05 13:22:10 <data>

I need to align D with A so that the times match. I fugure that if I use
something like the following it should work but I am not sure of the syntax
for looping or going to the next row.
What I want to code is:
If(C1<>A1)insert a row and move the data down until it does match, then go
to the next row and loop the code until EOF .....I tried to create the code
but failed...
For N=1 to 1000
IF(C1<>A1)
Range("C1").Select (how do I change C1 ...is it C1+1??)
Selection.Insert Shift:xlDown
Next



--
Nigel Forge

Re: Very basic code assistance please.... by Bob

Bob
Wed Feb 02 11:42:42 CST 2005

Nigel,

Try this

Sub ReOrder()
Dim cRows As Long
Dim i As Long

cRows = Cells(Rows.Count, "C").End(xlUp).Row
For i = cRows To 2 Step -1
Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
Next i
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nigel Forge" <nigelforge@hotmail.com(donotspam)> wrote in message
news:9B55B183-5DFA-42E3-B14F-AE34E7013657@microsoft.com...
> I need to align two rows of data containing date and time of equipment
> readings. One is taken every second and one every 3 seconds ....
> A B C
> D
> 02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
> 02/01/05 13:22:02 <data> 02/01/05 13:22:04 <data>
> 02/01/05 13:22:03 <data> 02/01/05 13:22:07 <data>
> 02/01/05 13:22:04 <data> 02/01/05 13:22:10 <data>
>
> I need to align D with A so that the times match. I fugure that if I use
> something like the following it should work but I am not sure of the
syntax
> for looping or going to the next row.
> What I want to code is:
> If(C1<>A1)insert a row and move the data down until it does match, then go
> to the next row and loop the code until EOF .....I tried to create the
code
> but failed...
> For N=1 to 1000
> IF(C1<>A1)
> Range("C1").Select (how do I change C1 ...is it C1+1??)
> Selection.Insert Shift:xlDown
> Next
>
>
>
> --
> Nigel Forge
>



Re: Very basic code assistance please.... by nigelforge

nigelforge
Wed Feb 02 16:45:02 CST 2005

Thanks ffor the effort Bob but the screen just jumps and flickers to infinity
and nothing changes. Am I supposed to add anything to your code or is it
complete?

Nigel

"Bob Phillips" wrote:

> Nigel,
>
> Try this
>
> Sub ReOrder()
> Dim cRows As Long
> Dim i As Long
>
> cRows = Cells(Rows.Count, "C").End(xlUp).Row
> For i = cRows To 2 Step -1
> Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
> Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
> Next i
> End Sub
>
> --
>
> HTH
>
> RP
> (remove nothere from the email address if mailing direct)
>
>
> "Nigel Forge" <nigelforge@hotmail.com(donotspam)> wrote in message
> news:9B55B183-5DFA-42E3-B14F-AE34E7013657@microsoft.com...
> > I need to align two rows of data containing date and time of equipment
> > readings. One is taken every second and one every 3 seconds ....
> > A B C
> > D
> > 02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
> > 02/01/05 13:22:02 <data> 02/01/05 13:22:04 <data>
> > 02/01/05 13:22:03 <data> 02/01/05 13:22:07 <data>
> > 02/01/05 13:22:04 <data> 02/01/05 13:22:10 <data>
> >
> > I need to align D with A so that the times match. I fugure that if I use
> > something like the following it should work but I am not sure of the
> syntax
> > for looping or going to the next row.
> > What I want to code is:
> > If(C1<>A1)insert a row and move the data down until it does match, then go
> > to the next row and loop the code until EOF .....I tried to create the
> code
> > but failed...
> > For N=1 to 1000
> > IF(C1<>A1)
> > Range("C1").Select (how do I change C1 ...is it C1+1??)
> > Selection.Insert Shift:xlDown
> > Next
> >
> >
> >
> > --
> > Nigel Forge
> >
>
>
>

Re: Very basic code assistance please.... by Bob

Bob
Wed Feb 02 17:20:45 CST 2005

Not possible. It might not do what you actually want, but there is insert.

I re-created your data, and it ended up like

02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
02/01/05 13:22:02 <data> <blank>
02/01/05 13:22:03 <data> <blank>
02/01/05 13:22:04 <data> 02/01/05 13:22:04 <data>
<blank>
<blank>
02/01/05 13:22:07
<data>
<blank>
<blank>
02/01/05 13:22:10
<data>


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nigel Forge" <nigelforge@hotmail.com(donotspam)> wrote in message
news:3CD99283-323E-4FC4-A0AE-A882D0698E6A@microsoft.com...
> Thanks ffor the effort Bob but the screen just jumps and flickers to
infinity
> and nothing changes. Am I supposed to add anything to your code or is it
> complete?
>
> Nigel
>
> "Bob Phillips" wrote:
>
> > Nigel,
> >
> > Try this
> >
> > Sub ReOrder()
> > Dim cRows As Long
> > Dim i As Long
> >
> > cRows = Cells(Rows.Count, "C").End(xlUp).Row
> > For i = cRows To 2 Step -1
> > Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
> > Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
> > Next i
> > End Sub
> >
> > --
> >
> > HTH
> >
> > RP
> > (remove nothere from the email address if mailing direct)
> >
> >
> > "Nigel Forge" <nigelforge@hotmail.com(donotspam)> wrote in message
> > news:9B55B183-5DFA-42E3-B14F-AE34E7013657@microsoft.com...
> > > I need to align two rows of data containing date and time of equipment
> > > readings. One is taken every second and one every 3 seconds ....
> > > A B C
> > > D
> > > 02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
> > > 02/01/05 13:22:02 <data> 02/01/05 13:22:04 <data>
> > > 02/01/05 13:22:03 <data> 02/01/05 13:22:07 <data>
> > > 02/01/05 13:22:04 <data> 02/01/05 13:22:10 <data>
> > >
> > > I need to align D with A so that the times match. I fugure that if I
use
> > > something like the following it should work but I am not sure of the
> > syntax
> > > for looping or going to the next row.
> > > What I want to code is:
> > > If(C1<>A1)insert a row and move the data down until it does match,
then go
> > > to the next row and loop the code until EOF .....I tried to create the
> > code
> > > but failed...
> > > For N=1 to 1000
> > > IF(C1<>A1)
> > > Range("C1").Select (how do I change C1 ...is it C1+1??)
> > > Selection.Insert Shift:xlDown
> > > Next
> > >
> > >
> > >
> > > --
> > > Nigel Forge
> > >
> >
> >
> >



Re: Very basic code assistance please.... by nigelforge

nigelforge
Thu Feb 03 11:29:07 CST 2005

Many thanks Bob

I realized that the data does not always follow the 2 second delay hence the
apparent error. I now need to configure the code to compare the date and time
values from col A with col C to see if they match and if they do then move on
if not then insert however many rows are needed to align the data.
If you can help further I would very much appreciate it, if not, then
thankls for what you haev done so far.

Nigel

"Bob Phillips" wrote:

> Not possible. It might not do what you actually want, but there is insert.
>
> I re-created your data, and it ended up like
>
> 02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
> 02/01/05 13:22:02 <data> <blank>
> 02/01/05 13:22:03 <data> <blank>
> 02/01/05 13:22:04 <data> 02/01/05 13:22:04 <data>
> <blank>
> <blank>
> 02/01/05 13:22:07
> <data>
> <blank>
> <blank>
> 02/01/05 13:22:10
> <data>
>
>
> --
>
> HTH
>
> RP
> (remove nothere from the email address if mailing direct)
>
>
> "Nigel Forge" <nigelforge@hotmail.com(donotspam)> wrote in message
> news:3CD99283-323E-4FC4-A0AE-A882D0698E6A@microsoft.com...
> > Thanks ffor the effort Bob but the screen just jumps and flickers to
> infinity
> > and nothing changes. Am I supposed to add anything to your code or is it
> > complete?
> >
> > Nigel
> >
> > "Bob Phillips" wrote:
> >
> > > Nigel,
> > >
> > > Try this
> > >
> > > Sub ReOrder()
> > > Dim cRows As Long
> > > Dim i As Long
> > >
> > > cRows = Cells(Rows.Count, "C").End(xlUp).Row
> > > For i = cRows To 2 Step -1
> > > Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
> > > Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
> > > Next i
> > > End Sub
> > >
> > > --
> > >
> > > HTH
> > >
> > > RP
> > > (remove nothere from the email address if mailing direct)
> > >
> > >
> > > "Nigel Forge" <nigelforge@hotmail.com(donotspam)> wrote in message
> > > news:9B55B183-5DFA-42E3-B14F-AE34E7013657@microsoft.com...
> > > > I need to align two rows of data containing date and time of equipment
> > > > readings. One is taken every second and one every 3 seconds ....
> > > > A B C
> > > > D
> > > > 02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
> > > > 02/01/05 13:22:02 <data> 02/01/05 13:22:04 <data>
> > > > 02/01/05 13:22:03 <data> 02/01/05 13:22:07 <data>
> > > > 02/01/05 13:22:04 <data> 02/01/05 13:22:10 <data>
> > > >
> > > > I need to align D with A so that the times match. I fugure that if I
> use
> > > > something like the following it should work but I am not sure of the
> > > syntax
> > > > for looping or going to the next row.
> > > > What I want to code is:
> > > > If(C1<>A1)insert a row and move the data down until it does match,
> then go
> > > > to the next row and loop the code until EOF .....I tried to create the
> > > code
> > > > but failed...
> > > > For N=1 to 1000
> > > > IF(C1<>A1)
> > > > Range("C1").Select (how do I change C1 ...is it C1+1??)
> > > > Selection.Insert Shift:xlDown
> > > > Next
> > > >
> > > >
> > > >
> > > > --
> > > > Nigel Forge
> > > >
> > >
> > >
> > >
>
>
>

RE: Very basic code assistance please.... by nigelforge

nigelforge
Thu Feb 03 12:05:04 CST 2005

Hi Bob

I want to say thanks as we managed to add the necessary code to make this
work for the erratic dates and times too as follows:

Private Sub CommandButton1_Click()

Dim cRows As Long
Dim i As Long

cRows = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To cRows Step 1
If (Worksheets("Sheet1").Range("A" & i) <>
Worksheets("Sheet1").Range("C" & i)) Then
Cells(i, "C").Resize(1, 2).Insert shift:=xlDown
End If
Next i


End Sub

Many thanks for giving us the basis of the code for this one.

Nigel

"Nigel Forge" wrote:

> I need to align two rows of data containing date and time of equipment
> readings. One is taken every second and one every 3 seconds ....
> A B C
> D
> 02/01/05 13:22:01 <data> 02/01/05 13:22:01 <data>
> 02/01/05 13:22:02 <data> 02/01/05 13:22:04 <data>
> 02/01/05 13:22:03 <data> 02/01/05 13:22:07 <data>
> 02/01/05 13:22:04 <data> 02/01/05 13:22:10 <data>
>
> I need to align D with A so that the times match. I fugure that if I use
> something like the following it should work but I am not sure of the syntax
> for looping or going to the next row.
> What I want to code is:
> If(C1<>A1)insert a row and move the data down until it does match, then go
> to the next row and loop the code until EOF .....I tried to create the code
> but failed...
> For N=1 to 1000
> IF(C1<>A1)
> Range("C1").Select (how do I change C1 ...is it C1+1??)
> Selection.Insert Shift:xlDown
> Next
>
>
>
> --
> Nigel Forge
>