Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2017, 09:05 AM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default deleting blanks and commas

NoSparks



Column "A
1 aaaa
2 blank
3 bbbb
4 blank
5 comma
7 cccc
6 blank
8 comma
9 dddd
10 eeee

Column "B"
1 aaaa
2 bbbb
3 cccc
4 dddd
5 eeee

I receive data in a vertical configuration (column "A"). However the data shows up in an inconsistent manner because the number of blank spaces separating the desired data varies. In addition, there are commas randomly included in the column "A". What I am wanting to do is to transfer the data in column "A" to column "B" so that each category of data (aaaa, bbbb, cccc, dddd,eeee) will reside in a constant address. What you have provided me so far does the job,.

However, I mistakenly specified to delete the "entire row" where blanks occurred instead of just deleting the "cell "where the blank occurred. I also neglected to mention where the commas occur that I want to those cells to be deleted as well.

In addition to the info you have provided,
Range("A1", Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlBlanks).EntireRow.D elete

if I just wanted to delete the blank cells, to would I change "EntireRow.Delete" ? And to what would I change (xlBlanks) to get rid of the commas?
Reply With Quote
  #2  
Old 03-01-2017, 10:29 AM
NoSparks NoSparks is offline deleting blanks and commas Windows 7 64bit deleting blanks and commas Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

You want to delete the cell but not the row ???
Okay, so what's to happen?
Cells from below move up or cells from the right move left?

Seeing column B is now in the picture, maybe this is what you need
Code:
Sub CopyInto_B()
    Dim lastrow As Long, writerow As Long
    Dim i As Long
    
With Sheets("Sheet1")
    lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
    writerow = 1
    For i = 1 To lastrow
        If .Cells(i, 1).Value <> "" And .Cells(i, 1).Value <> "," Then
            .Cells(writerow, 2).Value = .Cells(i, 1).Value
            writerow = writerow + 1
        End If
    Next i
End With
End Sub
Reply With Quote
  #3  
Old 03-01-2017, 10:58 AM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

Cells from below move up.
I will try your suggested procedure. All the same, I am curious regarding my question about changing "EntireRow.Delete" to "deleting the cell" and changing (xlBlanks) to what to get rid of the commas? Thanks once again.
Reply With Quote
  #4  
Old 03-01-2017, 11:36 AM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

Your solution works exactly as to what I need. I actually start at "A33" instead of "A1". I adjusted your code to reflect that. I would ask you to humor an old man and make a slight mod to the procedure. Could you extend the code to have the data in column "B" to overwrite the data in column "A" (starting at row 33)....keeping in mind that the number of rows in column A is greater than the number of rows in col B. In addition, would you make the data right justified in each cell. Presently the data received is a mixture of justification
Reply With Quote
  #5  
Old 03-01-2017, 12:43 PM
NoSparks NoSparks is offline deleting blanks and commas Windows 7 64bit deleting blanks and commas Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Hey..... stop with that old man stuff, I'm an Old Age Pensioner too ya know.

Except for the 33 and HorizontalAlignment this is what I had prior to seeing your last post.

xlBlanks is an built in constant.
In the vba environment, place your cursor within SpecialCells and hit F1 to find out things like this.

You could remove the commas to make those cells blank, then delete.
Code:
With Range("A33", Cells(Rows.Count, "A").End(xlUp))
    .Replace What:=",", Replacement:=""
    .SpecialCells(xlBlanks).Delete Shift:=xlUp
    .HorizontalAlignment = xlRight
End With
Reply With Quote
  #6  
Old 03-01-2017, 01:43 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

Senior citizen NoSparks,
Thank you for all your help on my project. This last assistance you provided me has gotten me to the final product. I am now ready to implement the program with which you have so generously helped me. Hopefully I will not encounter and glitches, but if I do I will be back. Thanking you and Jeffrey Brown for getting me to this point.
Reply With Quote
  #7  
Old 03-01-2017, 02:33 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

NoSparks,

Just when I thought I was ready to rock and roll, I encountered one more thing I need to make my program ready.
I have a spreadsheet (spreadsheet 1) that consist of multiple rows from which I will select one row and copy the data in that row to another spreadsheet (spreadsheet 2) for modification. I want to maintain the original data in spreadsheet 1 as it exist. After modifying that row of data within spreadsheet 2, I want to insert that modified row of data from spreadsheet 2 back into spreadsheet 1, above the original row that I copied from.
Can you help me with this issue?
Thanks in advance for any help regarding this
Reply With Quote
  #8  
Old 03-01-2017, 04:37 PM
NoSparks NoSparks is offline deleting blanks and commas Windows 7 64bit deleting blanks and commas Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

All questions this time...

How are you determining what original data row to copy?
Where do you put it on sheet2?
How do you manipulate the data? Manually or existing macro?
How do you insert the manipulated data back into sheet1?
Why are you doing all this?

Have you used the macro recorder to get an idea of how this would go in a macro?
Reply With Quote
  #9  
Old 03-01-2017, 05:21 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

How are you determining what original data row to copy?
I have large list of items that I downloaded from the internet that need to be modified. However I need to maintain a copy of the original.

Where do you put it on sheet2?
The data from sheet 1 is loaded into a form like configuration on sheet 2 for modification.

How do you manipulate the data? Manually or existing macro?
I use macros that I have made by recording and some which you and Jeffrey Brown have assisted me.

How do you insert the manipulated data back into sheet1?
Sheets("sheet 2").Range("A3:Z3").Copy
Sheets("sheet 1").Range("A7").Rows("1:1").Insert Shift:=xlDown

On a small spreadsheet this works fine, however it gets quite awkward with a large spreadsheet. I can function as it is but it would be more efficient and less cumbersome if I can reinsert the modified version above the original.

Why are you doing all this?
Helping someone...gratis

Have you used the macro recorder to get an idea of how this would go in a macro?
The problem with macro recorder is that it does not take into account that each time it will be a different row that must be inserted and pasted into.

I understand if you are a bit tired of contributing to my effort. Regardless, you have made significant contribution to my project and I appreciate all that you have offered.
Reply With Quote
  #10  
Old 03-01-2017, 05:28 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

The modified copies are variations of the original. There will be several variations of each original.
Reply With Quote
  #11  
Old 03-01-2017, 05:48 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

In addition to recording macros and assistance from this forum, I modify different things I find on the internet. That approach is trial and error. Mostly error. It has resulted in some successes. However, my latest issue has resulted in error so far.
Reply With Quote
  #12  
Old 03-01-2017, 06:41 PM
NoSparks NoSparks is offline deleting blanks and commas Windows 7 64bit deleting blanks and commas Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Hmmm... a couple of those questions didn't get interpreted the way I had hoped.

1.) How are you determining what original data row to copy?
In order to automate everything you need to know where to start, what row?
What is it that determines this? How can this be logically used in a macro?

2.) Why are you doing all this?
It's great that you're a nice guy, but what I was trying to get at was why do you take things from one sheet to another and back again?

an example as to why I ask... the move back and forth could be replaced by this if you knew what the row is and if it could be manipulated in place.
Code:
With Sheets("Sheet1").Rows(7)
    .Copy
    .Insert shift:=xlDown
Application.CutCopyMode = False
'now do the manipulation
End With
Reply With Quote
  #13  
Old 03-01-2017, 07:21 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

I click a cell in sheet 1 and run a macro that sends it to my sheet 2. This works fine. I determine which cell based upon the fact that it is an original and I need to add variations of that cell which will be done in sheet 2. This works fine.

I take things from one sheet (spreadsheet 1 containing all the rows of data) to a form sheet set up as a data entry form. Easier to look at one record in a form configuration than a spreadsheet that has columns a thru z and a boatload of rows. This works fine.

The whole program works good as it stands... but as it stands I return data to sheet 1 address "A7" thru "Z7" every time from sheet 2 row "A3" thru "Z3 ". What I want to do is copy data from sheet 2 (row "A3" thru "Z3 ") to an inserted row above the original copied row on sheet 1....and have the inserted row be the active row.

If I am able to accomplish what I want, the only constant will be the address of the copied data from sheet 2 (sheet 2 row "A3" thru "Z3 ") The row to paste that data on sheet 1 will always be a variable determined by the row I select for modification on sheet 2.
Reply With Quote
  #14  
Old 03-01-2017, 09:08 PM
NoSparks NoSparks is offline deleting blanks and commas Windows 7 64bit deleting blanks and commas Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Quote:
The whole program works good as it stands... but as it stands I return data to sheet 1 address "A7" thru "Z7" every time from sheet 2 row "A3" thru "Z3 ". What I want to do is copy data from sheet 2 (row "A3" thru "Z3 ") to an inserted row above the original copied row on sheet 1....and have the inserted row be the active row.
I suspect you get the original row to copy by referencing the active cell and want to do the same to copy back to sheet1.
You're needing to test things to see what happens.

Open a new workbook
Make A1 to A5, 1 thru 5
Select A3 to make it the active cell
Alt+F11 to bring up the VB environment
Ctrl+g to bring up the Immediate window
type in
rows(3).insert shift:=xldown
hit Enter..... is A3 not still the active cell and on the inserted row ?

The active cell can be used to determine the copy, insert and paste.
Reply With Quote
  #15  
Old 03-01-2017, 09:34 PM
FUGMAN FUGMAN is offline deleting blanks and commas Windows 10 deleting blanks and commas Office 2016
Banned
deleting blanks and commas
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

yes "A3" is the active cell and on the inserted row.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
pivot not showing number format with commas olybobo Excel 1 05-05-2016 05:09 PM
deleting blanks and commas Counting Blanks in 1 Column and Non-Blanks in Another dogwood705 Excel 4 02-07-2015 08:45 AM
Commas within fields in .csv files gar Excel 1 01-29-2015 09:24 PM
deleting blanks and commas How to use mid or left functions to seperate city,st,zip with no commas sinaranje Excel 4 11-11-2014 10:52 PM
deleting blanks and commas No inverted commas in word 2013. tonycrossley Word 3 01-27-2014 04:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft