Skip to content

Instantly share code, notes, and snippets.

View meganmcchesney's full-sized avatar

Megan McChesney meganmcchesney

  • ADI Global
  • Chippewa Falls, WI
View GitHub Profile
@meganmcchesney
meganmcchesney / @@IDENTITY insert
Last active December 14, 2015 05:59
Insert Content into Content and ContentBridge use TSQL @@IDENTITY function
USE CurtDev;
GO
--Create new ContentID for every T-Connector part in the Content table
--use last inserted identity value as variable, id
INSERT INTO Content(text, cTypeID)
VALUES ('Simple plug and play design eliminates the need for cutting or splicing', 2);
SELECT @@IDENTITY AS contentID
GO
@meganmcchesney
meganmcchesney / Weight Insert for CURT Dev
Created February 20, 2013 21:03
insert weights from PartPackage to PartAttribute where PartAttribute.field = 'weight' is null
use CurtDev
INSERT INTO PartAttribute (partID, value, field)
SELECT partID, weight, 'Weight'
FROM PartPackage
WHERE PartPackage.partID IN (
/*the group of partIDs to update*/
SELECT partID
FROM Part
WHERE partID NOT IN
@meganmcchesney
meganmcchesney / Lines2Rows Macro
Created February 13, 2013 20:02
Lines2Rows Macro breaks apart a cell based on a certain character, then inserts everything that is broken up into separate rows. Run from VBA, "Run Macro"
Sub Lines2Rows()
Dim rList As Range, rCell As Range
Dim lRow As Long
Dim vText As Variant
Set rList = Range("B1", Range("B" & Rows.Count).End(xlUp)) ' list
lRow = 1
For Each rCell In rList
If rCell <> "" Then
vText = Split(rCell, ";")
@meganmcchesney
meganmcchesney / VLookupAll Macro
Created February 13, 2013 19:59
VBA Macro "VLookupAll", which uses a vlookup of a column to produce a concatenated string of related cells. Runs with the formula: =vlookupall(A,A:B,2, ", ")
Function vlookupall(sSearch As String, rRange As Range, _
Optional lLookupCol As Long = 2, Optional sDel As String = ",") As String
'Vlookupall searches in first column of rRange for sSearch and returns
'corresponding values of column lLookupCol if sSearch was found. All these
'lookup values are being concatenated, delimited by sDel and returned in
'one string. If lLookupCol is negative then rRange must not have more than
'one column.
'Reverse("moc.LiborPlus.www") PB 16-Sep-2010 V0.20
Dim i As Long, sTemp As String
If lLookupCol > rRange.Columns.Count Or sSearch = "" Or _