Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Clueless about using cut and copy with offset

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default Clueless about using cut and copy with offset

Jeremiah,

Would you like the row that you are cutting from to be deleted once the
process is completed (as it should be blank)?

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Clueless about using cut and copy with offset

Just blank, deleting will misalign the rest of the spreadsheet

"Thomas [PBD]" wrote:

Jeremiah,

Would you like the row that you are cutting from to be deleted once the
process is completed (as it should be blank)?

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default Clueless about using cut and copy with offset

Jeremiah,

What I meant was that once the cutting is placed into the correct line the
line the data came from would be blank. Would you like it deleted. I wrote
this quick macro here where you can remove the ' in front of the delete
statement if you wish to use it.

Public Sub Cut_Offset()
y = Excel.WorksheetFunction.CountA(Columns("B:B"))

For x = 1 To y
If Cells(x, 2).Value = "Date" Then
If Cells(x, 3).Value = "" Then
Range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub

This will count the number of rows that say "Date" in Column B, copy the row
below it from C:O and place it the row above it. Optional delete blank row.

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

Just blank, deleting will misalign the rest of the spreadsheet

"Thomas [PBD]" wrote:

Jeremiah,

Would you like the row that you are cutting from to be deleted once the
process is completed (as it should be blank)?

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Clueless about using cut and copy with offset

Yes, the values can be deleted...Sorry, I maybe misunderstood there are too
many ways to say the same thing.
"Thomas [PBD]" wrote:

Jeremiah,

What I meant was that once the cutting is placed into the correct line the
line the data came from would be blank. Would you like it deleted. I wrote
this quick macro here where you can remove the ' in front of the delete
statement if you wish to use it.

Public Sub Cut_Offset()
y = Excel.WorksheetFunction.CountA(Columns("B:B"))

For x = 1 To y
If Cells(x, 2).Value = "Date" Then
If Cells(x, 3).Value = "" Then
Range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub

This will count the number of rows that say "Date" in Column B, copy the row
below it from C:O and place it the row above it. Optional delete blank row.

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

Just blank, deleting will misalign the rest of the spreadsheet

"Thomas [PBD]" wrote:

Jeremiah,

Would you like the row that you are cutting from to be deleted once the
process is completed (as it should be blank)?

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Clueless about using cut and copy with offset

I had to define some variables and not really confident in that task but have
this working. Problem is it stops abruptly at row 4051. There are a total
of 4588 rows in the spreadsheet and will grow each week. No obvious reason
staring me in the face that it would stop but perhaps my variables aren't
correct? Like I said, not vb educated so I may have done something
incorrectly.

Public Sub Cut_Offset()
Dim y As Single
Dim x As Single
y = Excel.WorksheetFunction.CountA(Columns("B:B"))

For x = 1 To y
If Cells(x, 2).value = "Date" Then
If Cells(x, 3).value = "" Then
range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub


"Thomas [PBD]" wrote:

Jeremiah,

What I meant was that once the cutting is placed into the correct line the
line the data came from would be blank. Would you like it deleted. I wrote
this quick macro here where you can remove the ' in front of the delete
statement if you wish to use it.

Public Sub Cut_Offset()
y = Excel.WorksheetFunction.CountA(Columns("B:B"))

For x = 1 To y
If Cells(x, 2).Value = "Date" Then
If Cells(x, 3).Value = "" Then
Range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub

This will count the number of rows that say "Date" in Column B, copy the row
below it from C:O and place it the row above it. Optional delete blank row.

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

Just blank, deleting will misalign the rest of the spreadsheet

"Thomas [PBD]" wrote:

Jeremiah,

Would you like the row that you are cutting from to be deleted once the
process is completed (as it should be blank)?

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default Clueless about using cut and copy with offset

Jeremiah,

I know the issue with this. The count is counting nonblank cells, so it is
counting that there are 4051 nonblanks, and 537 blank cells. You have two
options. Either delete the blank rows after Cutting the data, or setting the
reference to look at all rows regardless of blanks.

A) take the comment mark out of the Delete statement (')
B) y = Excel.WorksheetFunction.CountA(Columns("B:B")) +
Excel.WorksheetFunction.CountBlank(Columns("B:B"))

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''''Yes'''' below.


"jeremiah" wrote:

I had to define some variables and not really confident in that task but have
this working. Problem is it stops abruptly at row 4051. There are a total
of 4588 rows in the spreadsheet and will grow each week. No obvious reason
staring me in the face that it would stop but perhaps my variables aren't
correct? Like I said, not vb educated so I may have done something
incorrectly.

Public Sub Cut_Offset()
Dim y As Single
Dim x As Single
y = Excel.WorksheetFunction.CountA(Columns("B:B"))

For x = 1 To y
If Cells(x, 2).value = "Date" Then
If Cells(x, 3).value = "" Then
range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub


"Thomas [PBD]" wrote:

Jeremiah,

What I meant was that once the cutting is placed into the correct line the
line the data came from would be blank. Would you like it deleted. I wrote
this quick macro here where you can remove the ' in front of the delete
statement if you wish to use it.

Public Sub Cut_Offset()
y = Excel.WorksheetFunction.CountA(Columns("B:B"))

For x = 1 To y
If Cells(x, 2).Value = "Date" Then
If Cells(x, 3).Value = "" Then
Range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub

This will count the number of rows that say "Date" in Column B, copy the row
below it from C:O and place it the row above it. Optional delete blank row.

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

Just blank, deleting will misalign the rest of the spreadsheet

"Thomas [PBD]" wrote:

Jeremiah,

Would you like the row that you are cutting from to be deleted once the
process is completed (as it should be blank)?

--
--Thomas [PBD]
Working hard to make working easy.
Answered your question? Click ''Yes'' below.


"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Clueless about using cut and copy with offset

If the value in Column B = "Date" as a string would
be one thing, but if it = Date as a constant for today's
date then it another thing. But going with what you posted,
Then:

Sub cut_cpy()
Dim i As Long
For i = 2 To Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
If Range("B" & i) = "Date" And Range("C" & i & ":O" & i) _
.SpecialCells(xlCellTypeBlanks).Count = 13 Then
Range("C" & i + 1 & ":O" & i + 1).Cut _
Destination:=Range("C" & i)
End If
End With
Next
End Sub

"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Clueless about using cut and copy with offset

Yes, it is a string. "Date" being the row heading. I ran this and got a run
time error sayting no cells were found.

"JLGWhiz" wrote:

If the value in Column B = "Date" as a string would
be one thing, but if it = Date as a constant for today's
date then it another thing. But going with what you posted,
Then:

Sub cut_cpy()
Dim i As Long
For i = 2 To Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
If Range("B" & i) = "Date" And Range("C" & i & ":O" & i) _
.SpecialCells(xlCellTypeBlanks).Count = 13 Then
Range("C" & i + 1 & ":O" & i + 1).Cut _
Destination:=Range("C" & i)
End If
End With
Next
End Sub

"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Clueless about using cut and copy with offset

Three reasons why it would not find the cells.
1. Wrong sheet is active.
2. "Date" is not in column B.
3. There are no rows where All cells in Col C:O are blank.

The macro worked in a test set up.

"jeremiah" wrote:

Yes, it is a string. "Date" being the row heading. I ran this and got a run
time error sayting no cells were found.

"JLGWhiz" wrote:

If the value in Column B = "Date" as a string would
be one thing, but if it = Date as a constant for today's
date then it another thing. But going with what you posted,
Then:

Sub cut_cpy()
Dim i As Long
For i = 2 To Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
If Range("B" & i) = "Date" And Range("C" & i & ":O" & i) _
.SpecialCells(xlCellTypeBlanks).Count = 13 Then
Range("C" & i + 1 & ":O" & i + 1).Cut _
Destination:=Range("C" & i)
End If
End With
Next
End Sub

"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Clueless about using cut and copy with offset

I have checked and double checked and my case does not fit any of the 3
possibilities, I am looking at the correct sheet and column b does say Date
and there are rows where C through O are blank. Could it be there are spaces
behind the word Date (I tried with * and without), or perhaps because the
entire rows font and interior colors are conditionally formatted it is does
not appear the cells are blank?

"JLGWhiz" wrote:

Three reasons why it would not find the cells.
1. Wrong sheet is active.
2. "Date" is not in column B.
3. There are no rows where All cells in Col C:O are blank.

The macro worked in a test set up.

"jeremiah" wrote:

Yes, it is a string. "Date" being the row heading. I ran this and got a run
time error sayting no cells were found.

"JLGWhiz" wrote:

If the value in Column B = "Date" as a string would
be one thing, but if it = Date as a constant for today's
date then it another thing. But going with what you posted,
Then:

Sub cut_cpy()
Dim i As Long
For i = 2 To Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
If Range("B" & i) = "Date" And Range("C" & i & ":O" & i) _
.SpecialCells(xlCellTypeBlanks).Count = 13 Then
Range("C" & i + 1 & ":O" & i + 1).Cut _
Destination:=Range("C" & i)
End If
End With
Next
End Sub

"jeremiah" wrote:

I am trying to figure out the following....If the value of column B = "Date"
and columns C:O are empty, cut and copy the values from columns C:O in the
row directly below. Example below, the numbers in the row need to line up
with Date. The file was an imported csv file so sometimes the rows line up
and other times they don't.

Date
493,352 102.98 4,791 30.88 58,072 1,881


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
clueless where to start. qteekat Excel Worksheet Functions 3 January 4th 10 09:29 PM
VBA clueless - conditional colors and shapes Pivot Man[_2_] Excel Programming 0 July 25th 08 11:24 PM
HELP...CLUELESS... Thad Excel Discussion (Misc queries) 2 February 21st 07 02:20 AM
Find, Copy offset to offset on other sheet, Run-time 1004. Finny[_3_] Excel Programming 10 December 7th 06 11:46 PM
Excel VBA .Find method - am I clueless? Joe in Australia via OfficeKB.com Excel Programming 1 January 29th 06 11:02 AM


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