Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Update sheet one if data is not present.

Hello,

I have a xls sheet which contains "component name" in column B and "component
version" in column C. I have to update both of the columns regularly with new
components (in which case they are added to the bottom of the list) or if the
components are already in the list, then i simply update the component
version in column C. I was wodering if anybody new of a VBA script where i
could: -

paste my component and version list into sheet 2,
run the macro and the script would check if the component name already
existed in sheet 1, column B.
If the component already exists, then update the component version from sheet
2, column C to sheet 1, column C.
If the component does not exist, then add the component to the bottom of the
component list and copy over the component version from column C.
Run down column B and repeat the process in a loop until a blank cell is
reached.

Any help would be appreciated.

Thanks and regards,
Paul.

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Update sheet one if data is not present.


Sub UpdateVersion()

With Sheets("sheet1")
Sht1LastRow = Range("B" & Rows.Count).End(xlUp).Row
Newrow = Sht1LastRow + 1
End With
With Sheets("sheet2")
RowCount = 1
Do While .Range("B" & RowCount) < ""
Component = .Range("B" & RowCount)
Version = .Range("C" & RowCount)
With Sheets("sheet1")
Set c = .Columns("B").Find(what:=Component, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
c.Offset(0, 1) = Version
Else
.Range("B" & Newrow) = Component
.Range("C" & Newrow) = Version
Newrow = Newrow + 1
End If
End With
Loop
End With

End Sub
"par4724 via OfficeKB.com" wrote:

Hello,

I have a xls sheet which contains "component name" in column B and "component
version" in column C. I have to update both of the columns regularly with new
components (in which case they are added to the bottom of the list) or if the
components are already in the list, then i simply update the component
version in column C. I was wodering if anybody new of a VBA script where i
could: -

paste my component and version list into sheet 2,
run the macro and the script would check if the component name already
existed in sheet 1, column B.
If the component already exists, then update the component version from sheet
2, column C to sheet 1, column C.
If the component does not exist, then add the component to the bottom of the
component list and copy over the component version from column C.
Run down column B and repeat the process in a loop until a blank cell is
reached.

Any help would be appreciated.

Thanks and regards,
Paul.

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Update sheet one if data is not present.

Hi Joel,

Thanks for your prompt reply. I am having a little trouble with the script in
that it enters "Component" at the end of column B and "Version" at the end of
column C instead of updating the component version. I have written an example
of what was expected.

Sheet 1
Column B Column C
Component Version
component 1 version1
component 2 version2
component 3 version3
component 4 version4
component 5 version5

Sheet 2
Component Version
component 2 version2.1
component 3 version3.1
component 5 version5.1
component 6 version 1

Result for sheet 1
Component Version
component 1 version1
component 2 version2.1
component 3 version3.1
component 4 version4
component 5 version5.1
component 6 version 1

Can you help?
Thanks,
Paul.

Joel wrote:
Sub UpdateVersion()

With Sheets("sheet1")
Sht1LastRow = Range("B" & Rows.Count).End(xlUp).Row
Newrow = Sht1LastRow + 1
End With
With Sheets("sheet2")
RowCount = 1
Do While .Range("B" & RowCount) < ""
Component = .Range("B" & RowCount)
Version = .Range("C" & RowCount)
With Sheets("sheet1")
Set c = .Columns("B").Find(what:=Component, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
c.Offset(0, 1) = Version
Else
.Range("B" & Newrow) = Component
.Range("C" & Newrow) = Version
Newrow = Newrow + 1
End If
End With
Loop
End With

End Sub

Hello,

[quoted text clipped - 19 lines]
Thanks and regards,
Paul.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Update sheet one if data is not present.

The code is working the way it is suppose to, the data in your worksheet is
bad. The code will add the new lines to sheet 1 if the Component Names don't
EXACTLY match between sheets1 and sheet2. Check carefully for Extra spaces
(beginning and end in Column B), Compare Capitalization in the two sheets,
check for typo errors. Only the lines that don't match will be added to the
end.

I can modify the code to handle some of the mismatches if I knew what they
were.

"par4724 via OfficeKB.com" wrote:

Hi Joel,

Thanks for your prompt reply. I am having a little trouble with the script in
that it enters "Component" at the end of column B and "Version" at the end of
column C instead of updating the component version. I have written an example
of what was expected.

Sheet 1
Column B Column C
Component Version
component 1 version1
component 2 version2
component 3 version3
component 4 version4
component 5 version5

Sheet 2
Component Version
component 2 version2.1
component 3 version3.1
component 5 version5.1
component 6 version 1

Result for sheet 1
Component Version
component 1 version1
component 2 version2.1
component 3 version3.1
component 4 version4
component 5 version5.1
component 6 version 1

Can you help?
Thanks,
Paul.

Joel wrote:
Sub UpdateVersion()

With Sheets("sheet1")
Sht1LastRow = Range("B" & Rows.Count).End(xlUp).Row
Newrow = Sht1LastRow + 1
End With
With Sheets("sheet2")
RowCount = 1
Do While .Range("B" & RowCount) < ""
Component = .Range("B" & RowCount)
Version = .Range("C" & RowCount)
With Sheets("sheet1")
Set c = .Columns("B").Find(what:=Component, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
c.Offset(0, 1) = Version
Else
.Range("B" & Newrow) = Component
.Range("C" & Newrow) = Version
Newrow = Newrow + 1
End If
End With
Loop
End With

End Sub

Hello,

[quoted text clipped - 19 lines]
Thanks and regards,
Paul.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Update sheet one if data is not present.

Hi again Joel,

I am still struggling on this. I have looked to see if there are any typo's
and there does not appear to be any. The script just puts the word
"component" at the end of column B and the word "version" at the bottom of
column C. Am i missing something here? Would i be able to send you an xls
example?
i.e

Sheet 1
Column B Column C
Component Version
component 1 version1
component 2 version2
component 3 version3
component 4 version4
component 5 version5
component version
component version
component version
component version
component version

Thanks,
Paul.

Joel wrote:
The code is working the way it is suppose to, the data in your worksheet is
bad. The code will add the new lines to sheet 1 if the Component Names don't
EXACTLY match between sheets1 and sheet2. Check carefully for Extra spaces
(beginning and end in Column B), Compare Capitalization in the two sheets,
check for typo errors. Only the lines that don't match will be added to the
end.

I can modify the code to handle some of the mismatches if I knew what they
were.

Hi Joel,

[quoted text clipped - 64 lines]
Thanks and regards,
Paul.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Update sheet one if data is not present.

I found the problem. RowCount was being increnmented. sorry. I also change
the first row processed from 1 to 2.

Sub UpdateVersion()

With Sheets("sheet1")
Sht1LastRow = Range("B" & Rows.Count).End(xlUp).Row
Newrow = Sht1LastRow + 1
End With
With Sheets("sheet2")
RowCount = 2
Do While .Range("B" & RowCount) < ""
Component = .Range("B" & RowCount)
Version = .Range("C" & RowCount)
With Sheets("sheet1")
Set c = .Columns("B").Find(what:=Component, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
c.Offset(0, 1) = Version
Else
.Range("B" & Newrow) = Component
.Range("C" & Newrow) = Version
Newrow = Newrow + 1
End If
End With
RowCount = RowCount + 1
Loop
End With

End Sub




"par4724 via OfficeKB.com" wrote:

Hi again Joel,

I am still struggling on this. I have looked to see if there are any typo's
and there does not appear to be any. The script just puts the word
"component" at the end of column B and the word "version" at the bottom of
column C. Am i missing something here? Would i be able to send you an xls
example?
i.e

Sheet 1
Column B Column C
Component Version
component 1 version1
component 2 version2
component 3 version3
component 4 version4
component 5 version5
component version
component version
component version
component version
component version

Thanks,
Paul.

Joel wrote:
The code is working the way it is suppose to, the data in your worksheet is
bad. The code will add the new lines to sheet 1 if the Component Names don't
EXACTLY match between sheets1 and sheet2. Check carefully for Extra spaces
(beginning and end in Column B), Compare Capitalization in the two sheets,
check for typo errors. Only the lines that don't match will be added to the
end.

I can modify the code to handle some of the mismatches if I knew what they
were.

Hi Joel,

[quoted text clipped - 64 lines]
Thanks and regards,
Paul.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


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
Add data from other sheet to the data present in this sheet Nemo Excel Discussion (Misc queries) 1 January 29th 10 07:49 AM
Command to update data from one sheet to another Yitzhack Excel Worksheet Functions 6 June 25th 08 05:48 AM
Command to update data from one sheet to another Yitzhack New Users to Excel 1 June 25th 08 04:35 AM
testing whether a sheet is present Jeff Excel Programming 3 August 14th 05 04:07 PM
Update data at other sheet broogle Excel Programming 0 August 9th 05 04:54 AM


All times are GMT +1. The time now is 10:21 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"