rwmill9716
Active Member
- Joined
- May 20, 2006
- Messages
- 485
- Office Version
- 2013
- Platform
- Windows
BarryL provided me the start to the building the following Code. Essentially, it copies the data in columns C & D to columns G & H. It then reads the row shift factor in cell F5, and copies the data in columns E & F into columns G & H beginning in the shifted row. The data in columns G & H are shown here as they should be: rows 8 through 12 contain data from E & F, while rows 13 through 28 contain data from C & D. When I actually run the macro, however, rows 8 through 12 contain the correct E & F data, but rows 13 through 28 are blank. I need to define the end row for columns E & F which only copies that data, as it stands now it's copying all the data in columns E & F (data an blank cells) into G & H.
Code:
Sub Shift_Salt_Data()
Range("C8:D500").Select 'Copy Date and Data Columns to Holding Columns
Selection.Copy
Range("G8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim lr As Long, rowno As Long
Let lr = Range("E" & Rows.Count).End(xlUp).Row
Let rowno = Range("F5").Value
Range("E8:F" & lr).Copy
Range("G" & rowno).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub
Excel 2012 | ||||||||
---|---|---|---|---|---|---|---|---|
C | D | E | F | G | H | |||
4 | Shift Data to Row | Upper Spec = | 56.5 | |||||
5 | 8 | Lower Spec = | 55.5 | |||||
6 | Ppk = | 0.53 | ||||||
7 | Date/Time | 405Rsse.PH | Date/Time | 405Rssf.conc | Date | Composite | ||
8 | 1/1/2016 0:16:00 | 56.40999985 | 1/1/2016 0:17:00 | 56.35200119 | 1/1/16 0:17 | 56.35 | ||
9 | 1/2/2016 0:10:00 | 56.27399826 | 1/2/2016 0:10:00 | 56.39899826 | 1/2/16 0:10 | 56.40 | ||
10 | 1/2/2016 23:43:35 | 56.12400055 | 1/2/2016 23:43:58 | 56.25400162 | 1/2/16 23:43 | 56.25 | ||
11 | 1/4/2016 0:03:05 | 55.89500046 | 1/4/2016 0:03:24 | 55.60400009 | 1/4/16 0:03 | 55.60 | ||
12 | 1/5/2016 0:55:50 | 56.05099869 | 1/5/2016 0:55:00 | 56.06600189 | 1/5/16 0:55 | 56.07 | ||
13 | 1/6/2016 0:20:55 | 55.98799896 | 1/6/16 0:20 | 55.99 | ||||
14 | 1/8/2016 1:08:23 | 55.97800064 | 1/8/16 1:08 | 55.98 | ||||
15 | 1/9/2016 0:23:00 | 56.01399994 | 1/9/16 0:23 | 56.01 | ||||
16 | 1/10/2016 0:05:00 | 55.82699966 | 1/10/16 0:05 | 55.83 | ||||
17 | 1/10/2016 23:03:16 | 56.35800171 | 1/10/16 23:03 | 56.36 | ||||
18 | 1/11/2016 20:34:47 | 56.05099869 | 1/11/16 20:34 | 56.05 | ||||
19 | 1/12/2016 19:12:21 | 56.27399826 | 1/12/16 19:12 | 56.27 | ||||
20 | 1/13/2016 19:45:31 | 56.37799835 | 1/13/16 19:45 | 56.38 | ||||
21 | 1/14/2016 19:25:35 | 56.32600021 | 1/14/16 19:25 | 56.33 | ||||
22 | 1/15/2016 22:55:13 | 56.3370018 | 1/15/16 22:55 | 56.34 | ||||
23 | 1/17/2016 0:37:15 | 56.38399887 | 1/17/16 0:37 | 56.38 | ||||
24 | 1/17/2016 22:34:49 | 56.35200119 | 1/17/16 22:34 | 56.35 | ||||
25 | 1/18/2016 21:49:57 | 56.09799957 | 1/18/16 21:49 | 56.10 | ||||
26 | 1/19/2016 20:43:37 | 56.11299896 | 1/19/16 20:43 | 56.11 | ||||
27 | 1/21/2016 0:15:00 | 55.91600037 | 1/21/16 0:15 | 55.92 | ||||
28 | 1/21/2016 22:15:00 | 56.15499878 | 1/21/16 22:15 | 56.15 | ||||
Test |