ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Script that automatically writes (https://www.excelbanter.com/excel-discussion-misc-queries/176964-script-automatically-writes.html)

dangerd

Script that automatically writes
 
Hi there,

I have a very specific requirement but poor vba knowledge.

Basically I am looking for a script that will look a all the strings
contained within a range, compare it with data in another range and,
if there is data missing, append the missing data at the end of the
second range.

So it will go a little like this:

1- XL looks at all the data in colum A
2- Data in column A is then compared to that in column B
3- Is there are any difference, missing data is appended to column B

Has anyone got any ideas?

THx

D

Bob Phillips

Script that automatically writes
 
Public Sub ProcessData()
Dim i As Long
Dim iLastRow As Long

With Application

.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow

If IsError(Application.Match(.Cells(i, "A").Value, .Columns(1),
0)) Then

.Cells(.Range("B1").End(xlDown).Offset(1, 0).Row, "B").Value
= _
.Cells(i, "A").Value
End If
Next i

End With

With Application

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dangerd" wrote in message
...
Hi there,

I have a very specific requirement but poor vba knowledge.

Basically I am looking for a script that will look a all the strings
contained within a range, compare it with data in another range and,
if there is data missing, append the missing data at the end of the
second range.

So it will go a little like this:

1- XL looks at all the data in colum A
2- Data in column A is then compared to that in column B
3- Is there are any difference, missing data is appended to column B

Has anyone got any ideas?

THx

D




Rick Rothstein \(MVP - VB\)[_48_]

Script that automatically writes
 
See single inline comment...

"Bob Phillips" wrote in message
...
Public Sub ProcessData()
Dim i As Long
Dim iLastRow As Long

With Application

.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow

If IsError(Application.Match(.Cells(i, "A").Value, .Columns(1),
0)) Then


The 1 in your Columns(1) reference above should be a 2.

Rick



.Cells(.Range("B1").End(xlDown).Offset(1, 0).Row,
"B").Value = _
.Cells(i, "A").Value
End If
Next i

End With

With Application

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"dangerd" wrote in message
...
Hi there,

I have a very specific requirement but poor vba knowledge.

Basically I am looking for a script that will look a all the strings
contained within a range, compare it with data in another range and,
if there is data missing, append the missing data at the end of the
second range.

So it will go a little like this:

1- XL looks at all the data in colum A
2- Data in column A is then compared to that in column B
3- Is there are any difference, missing data is appended to column B

Has anyone got any ideas?

THx

D






All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com